1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <windows.h>
#include <soundfile.h>
HWND hwnd, hwndButton, icon_button;
HINSTANCE hInstance;
HICON hIcon1;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Static Control" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ; // error: undefined reference to `WndProc(HWND__*, unsigned int, unsigned int, long)@16'
wc.hCursor = LoadCursor(0,IDC_ARROW);
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
hwnd = CreateWindow( wc.lpszClassName, TEXT("Win32 Basic Window "),
WS_OVERLAPPEDWINDOW,
100, 100, 330, 270, 0, 0, hInstance, 0);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while( GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
WNDPROC OldButtonProc;
LRESULT CALLBACK ButtonProc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg) {
case WM_LBUTTONDOWN:
playsoundfile();
return 0;
case WM_LBUTTONUP:
stopsoundfile();
return 0;
}
return CallWindowProc (OldButtonProc, hwnd, msg, wp, lp);
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch(msg)
{
case WM_CREATE:
{
HWND hwndButton = CreateWindow(TEXT("button"), TEXT("Button"),
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
80, 10, 100, 50,
hwnd, (HMENU) buttonID, NULL, NULL);
OldButtonProc = (WNDPROC) SetWindowLong (hwndButton, GWL_WNDPROC, (LONG) ButtonProc);
hIcon1 = LoadIcon (NULL, IDI_WARNING);
SendMessage(icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
|