|
-
Aug 27th, 2001, 11:02 PM
#1
Thread Starter
Lively Member
Stop controls from floating around (and yes, they are children of the main form)
PHP Code:
#include <windows.h>
HINSTANCE trackinst;
HWND myform, pushbutton, editbox;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE myinst, HINSTANCE beforeinst, LPSTR cmds, int nFunsterStil) {
WNDCLASSEX wndcl;
MSG messages;
char szClassName[ ] = "WindowsApp";
trackinst = myinst;
wndcl.cbClsExtra = 0;
wndcl.cbSize = sizeof(WNDCLASSEX);
wndcl.cbWndExtra = 0;
wndcl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
wndcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wndcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndcl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndcl.hInstance = myinst;
wndcl.lpfnWndProc = WindowProc;
wndcl.lpszClassName = szClassName;
wndcl.lpszMenuName = NULL;
wndcl.style = 0;
if (!RegisterClassEx(&wndcl)) return 0;
myform = CreateWindowEx(0,
szClassName,
"Push the Button",
WS_BORDER || WS_CAPTION || WS_VISIBLE,
500, 500, 600, 300,
HWND_DESKTOP,
NULL,
myinst,
NULL);
ShowWindow(myform, nFunsterStil);
pushbutton = CreateWindowEx(0,
"BUTTON",
"Click me!",
WS_CHILD || WS_VISIBLE,
400, 75, 76, 150,
myform,
NULL,
myinst,
NULL);
ShowWindow(pushbutton, SW_SHOW);
editbox = CreateWindowEx(0,
"EDIT",
"jj",
WS_CHILD || WS_VISIBLE,
0, 100, 600, 26,
myform,
NULL,
myinst,
NULL);
ShowWindow(editbox, SW_SHOW);
while (GetMessage(&messages, NULL, 0, 0)) {
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam) {
switch (wMsg) {
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
if((HWND)lParam == pushbutton) {
SetWindowText(editbox, "Hello, world!");
}
}
return 0;
}
(Yes, I know some C++: I worked mainly with consoles but now am trying to go to Win32. With that, the difficulty level went way up!)
That was the entire code, I personally think it has something to do with the ShowWindow function for creating the form. I'll check back tomorrow, see ya!
- Justin Patrick Butler
Comme je trouve. "As I find."
- Butler family quote
Beneficia sumptos procul superant. "The benefits far exceed the costs."
- Myself
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|