#include "hypocyc.h"
#include "resource.h"
#include "stdafx.h"
#include <math.h>
#define IDM_OPT 1l
#define IDM_EXIT 2l
/*#define IDD_MY_DIALOG 10l
#define IDC_AEDIT 1l
#define IDC_BEDIT 12
#define IDC_CEDIT 13*/
#define IDOK2 2
#define IDD_MY_DIALOG 102
#define IDC_AEDIT 1000
#define IDC_BEDIT 1001
#define IDC_CEDIT 1002
#define IDC_STATIC -1
#define M_PI 3.14159265358
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
HWND HDialog ;
BOOL CALLBACK PropDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
static char szAppName[] = "Hypocycloide" ;
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
UINT i;
i=MB_ICONSTOP ;
wndclass.cbSize = sizeof (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 ;
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ;
RegisterClassEx (&wndclass) ;
HMENU hMenu = CreateMenu();
HMENU hMenuFile = CreatePopupMenu();
AppendMenu(hMenu,MF_STRING|MF_POPUP,(UINT)hMenuFile,"Ìåíþ");
AppendMenu(hMenuFile,MF_STRING,IDM_OPT,"Îïöèè");
AppendMenu(hMenuFile,MF_SEPARATOR,0,NULL);
AppendMenu(hMenuFile,MF_STRING,IDM_EXIT,"Âûõîä");
//HDialog = CreateMenu();
hwnd = CreateWindow (szAppName, // window class name
"Ãèïîöèêëîèäà", // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
hMenu, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, nCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
return 0;
}
double a=300,b=50,c=50;
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
int i;
HBRUSH hBrush;
HPEN hPen;
HLOCAL lk=0;
int x,y,xc,yc;
double t;
RECT rect ;
static HINSTANCE hInstance ;
// HINSTANCE hInstance ;
switch (iMsg)
{
case WM_CREATE:
//hInstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE) ;
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
break;
case WM_PAINT :
hdc = BeginPaint (hwnd, &ps);
hBrush = CreateSolidBrush (0x0000ff00);
SelectObject(hdc,hBrush);
//hPen = CreatePen (PS_SOLID,1,0x00000000) ;
//SelectObject(hdc,hPen);
GetClientRect (hwnd, &rect);
xc=(rect.right-rect.left)/2;
yc=(rect.bottom-rect.top)/2;
ExtFloodFill(hdc,xc,yc,0x00ffffff,FLOODFILLSURFACE);
MoveToEx(hdc,xc,yc+b-a+c,NULL);
for (t=0;t<=4*M_PI;t+=M_PI/200)
{
x=xc+(b-a)*sin(a/b*t)-c*sin((b-a)/b*t);
y=yc+(b-a)*cos(a/b*t)+c*cos((b-a)/b*t);
LineTo(hdc,x,y);
}
hBrush = CreateSolidBrush (0x00ffffff);
SelectObject(hdc,hBrush);
ExtFloodFill(hdc,xc+a+b,yc,0x0000ff00,FLOODFILLSURFACE);
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_COMMAND :
switch (LOWORD(wParam))
{
case IDM_OPT:
DialogBox (hInstance, LPSTR(IDD_MY_DIALOG), hwnd,
PropDlgProc);
return 0;
case IDM_EXIT:
SendMessage (hwnd, WM_CLOSE, 0, 0L) ;
return 0;
}
break ;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
BOOL CALLBACK PropDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
static HWND AEdit,BEdit,CEdit,OkBTN,CANCBTN ;
switch (iMsg)
{
case WM_INITDIALOG :
AEdit = GetDlgItem (hDlg, IDC_AEDIT) ;
BEdit = GetDlgItem (hDlg, IDC_BEDIT) ;
CEdit = GetDlgItem (hDlg, IDC_CEDIT) ;
OkBTN = GetDlgItem (hDlg, IDOK) ;
SetFocus (hDlg) ;
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
EndDialog (hDlg, TRUE) ;
return TRUE ;
case IDCANCEL :
EndDialog (hDlg, FALSE) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
Проблема с диалогом
Написал я програмку, вроде рисует, но как я вызываю диалого, она виснет. Почему, не скажете?