Używam visual studio 2010, kod:
#include <windows.h>
#include <cmath>
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' " "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
static TCHAR lpszAppName[] = TEXT( "API Windows v 1.0" );
static int windowWidth = 640;
static int windowHeight = 480;
double liczba1,liczba2,wynik;
HINSTANCE hInst;
HBITMAP hBitmap;
HINSTANCE hInstance;
//buttons
HWND button1;
#define ID_BUTTON1 501
//
HWND mathOperator;
#define ID_MATHOPERATOR 601
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
HDC hDC, hDC2;
PAINTSTRUCT ps;
switch (uMsg){
case WM_CREATE:
hBitmap = (HBITMAP)LoadImage(hInst, L"logo.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
break;
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
Rectangle(hDC, 3,3,108,108);
hDC2 = CreateCompatibleDC(hDC);
SelectObject(hDC2, hBitmap);
BitBlt(hDC,5,5,100,100,hDC2,0,0,SRCCOPY);
DeleteObject(hDC2);
EndPaint(hWnd, &ps);
break;
case WM_COMMAND:
switch(wParam){
case ID_BUTTON1:
MessageBox(hWnd, L" Application Created By \n Copyright @ 2013", lpszAppName, MB_OK);
break;
default:
break;
}
break;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == GetDlgItem(hWnd, ID_MATHOPERATOR)) {
// we're about to draw the static
// set the text colour in (HDC)lParam
SetBkMode((HDC)wParam, RGB(255,255,0));
SetTextColor((HDC)wParam, RGB(205,55,25));
return (BOOL)CreateSolidBrush (GetSysColor(COLOR_MENU));
}
break;
case WM_CLOSE:
if(MessageBox(hWnd,L"Czy chcesz zamknąć aplikację ?", lpszAppName, MB_YESNO) == IDYES){
PostQuitMessage(0);
}
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return(0L);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
WNDCLASS wndclass;
HWND hWnd;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = MainWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszAppName;
hInst = hInstance;
if(RegisterClass(&wndclass) == 0)
return FALSE;
hWnd = CreateWindow(
lpszAppName, lpszAppName,
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
100, 100, windowWidth, windowHeight,
NULL, NULL, hInstance, NULL);
if(hWnd == NULL) {
return FALSE;
}else {
//buttons
button1 = CreateWindowEx(WS_EX_CLIENTEDGE , L"button", L"About", WS_CHILDWINDOW | WS_VISIBLE, 3, 108, 108, 20, hWnd, (HMENU) ID_BUTTON1, hInstance, NULL);
//
mathOperator = CreateWindowEx(WS_EX_APPWINDOW, L"static", L"+", WS_CHILDWINDOW | WS_VISIBLE, 110, 110, 50, 50, hWnd, (HMENU) ID_MATHOPERATOR, hInstance, NULL);
}
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
SS:
@nobody__, stamtąd wziąłem właśnie ten pragma comment, bo manifestu nie wiem zbytnio jak dodać
@Azarien chciałem załączyć stdafx.h ale nie mam.