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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
// CppWin32Dialog.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "CppWin32Dialog.h"
#include <CommCtrl.h>
// For nice controls look
#pragma comment(linker, \
"\"/manifestdependency:type='Win32' "\
"name='Microsoft.Windows.Common-Controls' "\
"version='6.0.0.0' "\
"processorArchitecture='*' "\
"publicKeyToken='6595b64144ccf1df' "\
"language='*'\"")
#pragma comment(lib, "ComCtl32.lib")
INT_PTR CALLBACK DialogProc(HWND ,UINT ,WPARAM ,LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HWND hDlg;
MSG msg;
BOOL ret;
InitCommonControls();
hDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(frmMain), 0, DialogProc, 0);
ShowWindow(hDlg, nCmdShow);
// Main message loop:
while((ret = GetMessage(&msg, 0, 0, 0)) != 0)
{
if(ret == -1)
return -1;
if(!IsDialogMessage(hDlg, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDOK:
PostQuitMessage(0);
break;
case IDCANCEL:
::MessageBox (hDlg, "Checking cancel",
"Retro Label", MB_ICONINFORMATION | MB_OK);
break;
// My button drawn in resource editor
case IDShowText:
/*// char array to hold the text from the textbox
TCHAR szInput[MAX_PATH];
// Obtains input from the textbox and puts it into the char array
GetWindowText(hDlg, szInput, MAX_PATH);
// message box is correctly displayed
::MessageBox (hDlg, L"Checking show text",
L"Retro Label", MB_ICONINFORMATION | MB_OK);*/
//No lines are drawn
hdc = BeginPaint(hDlg, &ps);
MoveToEx(hdc,100,100,0); // move the drawing position to 100, 100
LineTo(hdc,150,150); // draw a line from the drawing position to 150, 150
MoveToEx(hdc,200,200,0); // move the drawing position to 200, 200
LineTo(hdc,300,200);
EndPaint(hDlg, &ps);
}
break;
case WM_PAINT:
//Trying to draw a line
/*hdc = BeginPaint(hDlg, &ps);
MoveToEx(hdc, 60, 20, NULL);
LineTo(hdc, 264, 122);
// TODO: Add any drawing code here...
EndPaint(hDlg, &ps);*/
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return (INT_PTR)FALSE;
}
|