-
why
why wont this work
Code:
/****************************************************************************/
/* created by:adam *
/* on 2-21-02 *
/* *
/* *
/* *
/* *
/* *
/* *
/****************************************************************************/
#include <windows.h>
#include <stdio.h>
#define ID_CONNECT 2556;
#define ID_SEND 2557
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof (wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL,NULL);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "client";
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
RegisterClassEx (&wndclass);
hwnd = CreateWindow ("client",
"client",
WS_POPUP,
200,
150,
600,
400,
NULL,
NULL,
hInstance,
NULL);
HWND hWndConnect = CreateWindow(TEXT("BUTTON"),
TEXT("Connect"),
BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE,
10,
10,
65,
15,
hwnd,
(HMENU)ID_CONNECT,
hInstance,
NULL ) ;
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_LBUTTONDOWN:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(wParam)
{
case ID_CONNECT:
MessageBox(hWnd, "Button was clicked!!!", "Event...", MB_OK);
PostQuitMessage(0);
break;
}
break;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam);
}
-
What's the problem? What's going wrong? I have a couple of ideas, but I need to know your error. Is it a compile-time error? Runtime? Something just not doing what you expect?
-
Why are you creating the window with param WS_POPUP?
-
Can you spot what's wrong with this -
#define ID_CONNECT 2556;
2556; will be substituted where ever the preprocessor sees ID_CONNECT.
-
The smallest things... :p
-
the thing im reading told me to define it to a number
and the errors are things like missing ; after the : when there already is one and a missing ) before ; when there already is one
and they are all compile time errors
-
>and they are all compile time errors
I know, and they'll be confusing errors because your macro is wrong. You don't want the semi-colon after the number, or that'll be substituted into your code aswell which will confuse the hell out of your compiler.
//incorrect
#define ID_CONNECT 2556;
//correct
#define ID_CONNECT 2556