Механизмы параллельных вычислений в Windows. Разработка справочной системы
Рефераты >> Программирование и компьютеры >> Механизмы параллельных вычислений в Windows. Разработка справочной системы

void InitMainDlg(HWND hWnd)

{

// This structure describes the fixed portion at the begining of a

// dialog template. The part we are going to modify is dtItemCount

// to cause the proper number of drive selector boxes to display.

WORD numDrives;

#if !defined( FLAT )

// 16 bit dialog template

typedef struct tagDLGTEMPLATE

{

long dtStyle;

BYTE dtItemCount;

int dtX;

int dtY;

int dtCX;

int dtCY;

char dtResourceName[1];

} DLGTEMPLATE;

typedef LPSTR DLGPTR;

#else

// 32 bit dialog template

typedef struct tagDLGTEMPLATE

{

DWORD dtStyle;

DWORD dtExtStyle;

WORD dtItemCount;

SHORT dtX;

SHORT dtY;

SHORT dtCX;

SHORT dtCY;

} DLGTEMPLATE;

typedef LPCDLGTEMPLATEA DLGPTR;

#endif

DLGTEMPLATE FAR *dltp, *tempDlgPtr;

LPCSTR resourceStr;

HRSRC resourceHndl;

// Modifying dialog box parms on the fly.

// Load the dialog box resource.

resourceStr = MAKEINTRESOURCE(IDD_MAIN);

// CreateDialogIndirect(hInst,resourceStr,hWnd,(DLGPROC)lpModelessProc);

resourceHndl = FindResource(hInst, resourceStr, RT_DIALOG);

hdlgr = LoadResource(hInst, resourceHndl);

if (hdlgr)

{

// Lock the resource so we have a pointer to it.

dltp = (DLGTEMPLATE FAR *) LockResource(hdlgr);

if (dltp)

{

// Change the number of items to display. The drive boxes are

// defined last so we can truncate the ones not needed.

// make a temporary copy of dialog template

tempDlgPtr = (DLGTEMPLATE*) malloc((size_t)SizeofResource(hInst, resourceHndl));

#if defined( FLAT )

memcpy((void *)tempDlgPtr, (const void *)dltp, (size_t)SizeofResource(hInst, resourceHndl));

#else

_fmemcpy((void FAR *)tempDlgPtr, (const void FAR *)dltp, (size_t)SizeofResource(hInst, resourceHndl));

#endif

CreateDialogIndirect(hInst,

(DLGPTR)tempDlgPtr,

hWnd,

(DLGPROC)lpModelessProc);

// free tempory copy of dialog template

free(tempDlgPtr);

// Unlock dialog resource we locked above.

#if !defined( FLAT )

UnlockResource(hdlgr);

#endif

// Free it.

FreeResource(hdlgr);

// Zero handle to it.

hdlgr = 0;

}

}

}

//*******************************************************************

// MainDlgBoxProc - handle Main dialog messages (modeless)

//

// This is a modeless dialog box procedure that controls this

// entire application.

//

// paramaters:

// hDlg - The window handle for this message

// message - The message number

// wParam - The WPARAM parameter for this message

// lParam - The LPARAM parameter for this message

//

//*******************************************************************

#pragma argsused

BOOL CALLBACK MainDlgBoxProc(HWND hDlg, UINT message,

WPARAM wParam, LPARAM lParam)

{

// static HWND hlistwnd;

static RECT wrect;

int index[27];

char buf[256];

int x, y, w, h, i;

switch (message)

{

case WM_INITDIALOG:

// Save the handle of this proc for use by main window proc.

hQryDlgBox = hDlg;

// Get position of dialog box window.

GetWindowRect(hDlg, (LPRECT) &wrect);

w = wrect.right - wrect.left;

h = wrect.bottom - wrect.top;

// Move main application window to same position.

SetWindowPos(hWndMain, hDlg,

wrect.left, wrect.top, w, h,

0);

hMenuAvt=CreatePopupMenu();

AppendMenu(hMenuAvt,MF_ENABLED|MF_STRING,IDM_ABOUT, "&About");

hMenuFile=CreatePopupMenu();

AppendMenu(hMenuFile,MF_ENABLED|MF_STRING,IDM_EXIT, "&Выход");

hMenu = CreateMenu();

AppendMenu(hMenu, MF_ENABLED|MF_POPUP, (UINT) hMenuFile, "&Файл");

AppendMenu(hMenu, MF_ENABLED|MF_POPUP, (UINT) hMenuAvt, "&О программе");

SetMenu(hDlg, hMenu);

break;

case WM_MOVE:

// Always keep this dialog box on top of main window.

GetWindowRect(hWndMain, (LPRECT) &wrect);

x = wrect.left;

y = wrect.top;

w = wrect.right - wrect.left;

h = wrect.bottom - wrect.top;

MoveWindow(hDlg, x, y, w, h, 1);

break;

case WM_SYSCOMMAND:

// Pass WM_SYSCOMMAND messages on to main window so both

// main window and dialog box get iconized, minimized etc.

// in parallel.

SendMessage(hWndMain, message, wParam, lParam);

break;

case WM_RBUTTONUP:

if(flag)

if(LOWORD(lParam)>290 && LOWORD(lParam)<410 && HIWORD(lParam)> 90 && HIWORD(lParam)<210){

GetCurrentDirectory(256,buf);

strcat(buf,"/help/Shapes.hlp");

WinHelp(hDlg,buf,HELP_CONTENTS,0);

};

break;

case WM_COMMAND:

switch (GET_WM_COMMAND_ID(wParam, lParam))

{

case IDC_OK3:

ShowWindow(hDlg,SW_HIDE);

ShowWindow(hDlg,SW_SHOW);

break;

case IDM_EXIT:

PostMessage(hWndMain, WM_CLOSE, 0, 0L);

// Destroy ourseleves.

DestroyWindow(hDlg);

break;

case IDM_ABOUT:

DialogBox(hInst, (LPCTSTR)IDD_ABOUT, hDlg, (DLGPROC)About);

break;

case IDC_SELECT:

DialogBox(hInst, (LPCTSTR)IDD_SELECT, hDlg, (DLGPROC)Select);

break;

default:

break;

}

break;

case WM_PAINT:

hdc = BeginPaint(hDlg, &ps);

// TODO: Add any drawing code here .

RECT rt;

GetClientRect(hDlg, &rt);

//---------------------------------------

PaintShapes(hDlg);

//--------------------------------

EndPaint(hDlg, &ps);

break;

case WM_CLOSE:

// Unlock dialog resource we locked above.

#if !defined( FLAT )

UnlockResource(hdlgr);

#endif

// Free it.

FreeResource(hdlgr);

// Zero handle to it.

hdlgr = 0;

// Zero handle to this dialog window.

hQryDlgBox = 0;

// Tell main window to close.

PostMessage(hWndMain, WM_CLOSE, 0, 0L);

// Destroy ourseleves.

DestroyWindow(hDlg);

break;

default:

return FALSE;

}

return(TRUE);

}

// Mesage handler for about box.

LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

{

switch (message)

{

case WM_INITDIALOG:

return TRUE;

case WM_COMMAND:

if (LOWORD(wParam) == IDC_OK1)

{

EndDialog(hDlg, LOWORD(wParam));

return TRUE;

}

break;

}

return FALSE;

}

// заполнение ListBox списком фигур

void fillb(HWND hDlg, int ID)

{

SendDlgItemMessage(hDlg,ID,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)"горизонтальная линия");

SendDlgItemMessage(hDlg,ID,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)"квадрат");

SendDlgItemMessage(hDlg,ID,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)"шестиугольник");

SendDlgItemMessage(hDlg,ID,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)"восьмиугольник");

SendDlgItemMessage(hDlg,ID,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)"крест");


Страница: