()
Newbie
Messaggi:
Iscritto:
|
Eccomi,
sono esasperato perché non trovo la soluzione al mio dilemma.
Sono arrivato a scrivere un button in un form con le API di Windows.
Codice sorgente - presumibilmente C# |
#include <windows.h> LRESULT CALLBACK WndProc(HWND handle, UINT message, WPARAM wparam, LPARAM lparam); int WINAPI WinMain(HINSTANCE instanza, HINSTANCE hPrevInstance, LPSTR argomenti, int stato); HWND button; int WINAPI WinMain(HINSTANCE instanza, HINSTANCE hPrevInstance, LPSTR argomenti, int stato) { WNDCLASS window; window.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); window.hCursor = LoadCursor(NULL, IDC_ARROW); window.hIcon = LoadIcon(NULL, IDI_APPLICATION); window.hInstance = instanza; window.lpszClassName = TEXT("Form"); window.cbClsExtra = 0; window.cbWndExtra = 0; window.style = CS_HREDRAW | CS_VREDRAW; window.lpszMenuName = 0; window.lpfnWndProc = WndProc; RegisterClass(&window); HWND windowHandle = CreateWindow(TEXT("Form"), TEXT("Darken Rahl's Form"), WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, instanza, NULL); ShowWindow(windowHandle, stato); UpdateWindow(windowHandle); MSG messaggio; while(GetMessage(&messaggio, NULL, 0, 0)) { TranslateMessage(&messaggio); DispatchMessage(&messaggio); } return messaggio.wParam; } LRESULT CALLBACK WndProc(HWND handle, UINT message, WPARAM wparam, LPARAM lparam) { switch(message) { case WM_CREATE: button = CreateWindow("Button", "Clicca", WS_VISIBLE | WS_CHILD, 10, 10, 50, 50, handle, (HMENU)10, (HINSTANCE)GetWindowLong(handle, GWL_HINSTANCE), NULL); return 0; break; case WM_PAINT: HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(handle, &ps); EndPaint(handle, &ps); return 0; break; case WM_COMMAND: if (LOWORD(wparam) == 10) MessageBox(handle, "Hai cliccato il bottone", ":O", MB_OK); return 0; break; case WM_DESTROY: PostQuitMessage( 0 ) ; return 0; break; } return DefWindowProc(handle, message, wparam, lparam); }
|
Ma la mia domanda più importante è : "Come faccio ad inserire un'immagine da un file nel button?"
Vi prego di aiutarmi, voglio conoscere e capire (possibilmente) come si fa.
|