Estou aprendendo C++ para win32, mais ta muito mais ph0d@ que Java. Eu não quero depender de nenhum IDE como VS então estou tentando aprender sem “desenhar interfaces”, mais programa-las no braço.
resorce.rc:
#include "resource.h" // REcursos
DLG_MAIN DIALOGEX 6, 5, 194, 106
CAPTION "First C++ win project"
FONT 8, "Tahoma"
STYLE 0x10CE0804
BEGIN
CONTROL "&Test", IDC_BTN_TEST, "Button", 0x10010000, 138, 5, 46, 15
CONTROL "&Quit", IDC_BTN_QUIT, "Button", 0x10010000, 138, 29, 46, 15
CONTROL "EXIBE", IDC_BTN_SHOW, "Button", 0x10010000, 138, 50, 46, 15
END
resorce.h
#include <windows.h> // resorces(resorce.h)
// ID of Main Dialog
#define DLG_MAIN 101
// ID of Button Controls
#define IDC_BTN_TEST 1001
#define IDC_BTN_QUIT 1002
#define IDC_BTN_SHOW 1003
Projeto principal (main.cpp)
[code]#define WIN32_LEAN_AND_MEAN //Main.cpp(arquivo principal)
#include <windows.h>
#include “resource.h”
HINSTANCE hInst;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
/*
* TODO: Add code to initialize the dialog.
*/
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
/*
* TODO: Add more control ID's, when needed.
*/
case IDC_BTN_SHOW: // Erro, invalid conversion from 'int' do constant CHAR*;
MessageBox(hwndDlg, "Consegui adicionar eventos a botões", MB_ICONINFORMATION);
return TRUE;// Erro, invalid conversion from 'int' do constant CHAR*;
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_TEST:
MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);
return TRUE;
}
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);
}
[/code]