Subject:
Re: A one button program
From:
Marek Peca ####@####.####
Date:
7 Sep 2000 17:07:01 -0000
Message-Id: <Pine.LNX.4.10.10009071706260.13809-200000@tynska.cuni.cz>
Hello,
yes, you forgot a MwRegisterButtonControl call -- I've written you about
it twice, also in my sample program it is (i attach it for others to look
-- very ugly, but I've no time now to tidy it).
Marek.
> I am having problems displaying a button on my form. A blank empty for
> shows up ok but no button. My code follows below. Do you see any problem
> with it?
#include <microwin/windows.h>
UINT stuff;
HWND tlac, mlac;
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
WNDCLASS wc;
HWND hWnd;
MSG msg;
wc.cbClsExtra = 0; wc.cbWndExtra = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
wc.lpszClassName = "HlavniOkno";
RegisterClass(&wc);
hWnd = CreateWindowEx(0L, wc.lpszClassName, "Titulek!", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 600, 400, NULL, NULL, hInstance, NULL);
MwRegisterButtonControl(NULL);
tlac = CreateWindowEx(0L, "BUTTON", "Staniz se.",BS_DEFPUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_BORDER,
300,200,100,40,hWnd,NULL,hInstance,NULL);
tlac = CreateWindowEx(0L, "BUTTON", "??",/* BS_PUSHBUTTON| */ WS_CHILD|WS_VISIBLE|WS_BORDER,
450,200,100,40,hWnd,NULL,hInstance,NULL);
MwRegisterStaticControl(NULL);
CreateWindowEx(0L, "STATIC", "320 K", WS_BORDER|SS_CENTER|WS_CHILD|WS_VISIBLE, 30, 100, 40, 20, hWnd,NULL,hInstance,NULL);
MwRegisterEditControl(NULL);
CreateWindowEx(0L, "EDIT", "prd", WS_CHILD|WS_VISIBLE, 30, 200, 400, 20, hWnd,NULL,hInstance,NULL);
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while (GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
void Napis(HWND hWnd, int zam)
{
HDC dc;
dc = GetDC(hWnd);
SetBkColor(dc, RGB(0,0,0));
SetTextColor(dc, RGB(255,200,0));
if (zam)
TextOut(dc, 30, 30, "At zije Slunicko!", 17);
else
TextOut(dc, 30, 30, "In saecula.", 11);
ReleaseDC(hWnd, dc);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_COMMAND: {
Napis(hWnd, (lParam == tlac));
break;
}
case WM_DESTROY: {
PostQuitMessage(0);
break;
}
default:
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return(0);
}