Here's the .c file:
Code:
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static TCHAR szAppName[] = TEXT("Aquamarine");
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = szAppName;
wndclass.lpszClassName = szAppName;
if(!RegisterClass(&wndclass)){
MessageBox(NULL, TEXT("Error registering window class."),
szAppName, MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(szAppName, TEXT("Aquamarine"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 500, 300, NULL, NULL,
hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0) > 0){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HMENU hMenu;
switch(message)
{
case WM_COMMAND:
hMenu = GetMenu(hwnd);
switch(LOWORD(wParam))
{
case ID_REGISTER:
MessageBox(NULL, TEXT("Esta opção não funciona ainda.\r\nAguarde e confie..."),
szAppName, MB_ICONWARNING);
return 0;
case ID_BUY:
MessageBox(NULL, TEXT("Esta opção não funciona ainda.\r\nAguarde e confie..."),
szAppName, MB_ICONWARNING);
return 0;
case ID_PAYMENT:
MessageBox(NULL, TEXT("Esta opção não funciona ainda.\r\nAguarde e confie..."),
szAppName, MB_ICONWARNING);
return 0;
case ID_RETURN:
MessageBox(NULL, TEXT("Esta opção não funciona ainda.\r\nAguarde e confie..."),
szAppName, MB_ICONWARNING);
return 0;
case ID_SEARCH_NAME:
MessageBox(NULL, TEXT("Esta opção não funciona ainda.\r\nAguarde e confie..."),
szAppName, MB_ICONWARNING);
return 0;
case ID_SEARCH_PHONE:
MessageBox(NULL, TEXT("Esta opção não funciona ainda.\r\nAguarde e confie..."),
szAppName, MB_ICONWARNING);
return 0;
case ID_APP_EXIT:
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 0;
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
Here's the .h file:
Code:
#define ID_REGISTER 101
#define ID_APP_EXIT 102
#define ID_BUY 103
#define ID_PAYMENT 104
#define ID_RETURN 105
#define ID_SEARCH_NAME 106
#define ID_SEARCH_PHONE 107
And here's the .rc file:
Code:
#include "resource.h"
AQUAMARINE MENU DISCARDABLE
BEGIN
POPUP "&Cliente novo"
BEGIN
MENUITEM "&Cadastrar", ID_REGISTER
MENUITEM SEPARATOR
MENUITEM "S&air", ID_APP_EXIT
END
POPUP "&Transações"
BEGIN
MENUITEM "&Compra", ID_BUY
MENUITEM "&Pagamento", ID_PAYMENT
MENUITEM "&Devolução", ID_RETURN
END
POPUP "&Procurar"
BEGIN
MENUITEM "&Por nome", ID_SEARCH_NAME
MENUITEM "&Por telefone", ID_SEARCH_PHONE
END
POPUP "&Sobre"
BEGIN
MENUITEM "&Sobre o programa...", ID_ABOUT
END
END
This is what happens when I try to compile this program:
c:\Documents and Settings\kao\My Documents\Visual Studio Projects\GUI\resource.h(11): fatal error RC1004: unexpected end of file found
c:\Documents and Settings\kao\My Documents\Visual Studio Projects\GUI\GUI.cpp(44): warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
Any ideas? Thanks.