Added uiControlHandle() and fixed other uiButton issues.

This commit is contained in:
Pietro Gagliardi 2015-04-07 04:12:03 -04:00
parent a7293951f7
commit 3b52095ab0
4 changed files with 15 additions and 1 deletions

View File

@ -38,6 +38,7 @@ uiControl *uiNewButton(const char *text)
struct button *b;
uiWindowsNewControlParams p;
WCHAR *wtext;
HWND hwnd;
b = uiNew(struct button);
@ -52,9 +53,12 @@ uiControl *uiNewButton(const char *text)
p.data = b;
b->c = uiWindowsNewControl(&p);
hwnd = (HWND) uiControlHandle(b->c);
wtext = toUTF16(text);
// TODO set text
if (SetWindowTextW(hwnd, wtext) == 0)
logLastError("error setting button text in uiNewButton()");
uiFree(wtext);
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
b->onClicked = defaultOnClicked;

View File

@ -54,3 +54,9 @@ void uiQuit(void)
{
PostQuitMessage(0);
}
// TODO move somewhere else
uintptr_t uiControlHandle(uiControl *c)
{
return (*(c->handle))(c);
}

View File

@ -16,6 +16,7 @@ void uiMain(void);
void uiQuit(void);
typedef struct uiControl uiControl;
uintptr_t uiControlHandle(uiControl *);
typedef struct uiWindow uiWindow;
uiWindow *uiNewWindow(char *, int, int);

View File

@ -1,6 +1,9 @@
// 6 april 2015
#include "uipriv_windows.h"
// TODOs:
// - child not set to fit initial size
struct uiWindow {
HWND hwnd;
uiControl *child;