/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 12 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1990-2001 by LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ #define STRICT #include #include #include "resource.h" #include "Segdem.h" // Global variables L_TCHAR szFrameClass[] = TEXT ("SegmentFrame"); L_TCHAR szChildClass[] = TEXT ("SegmentFormChild"); HMENU hMenuInitWindow, hMenuChildWindow; HMENU hMenuInit, hMenuChild, hContextMenu, hContextCombineMenu; HWND hwndFrame, hwndClient; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { HACCEL hAccel; MSG msg; WNDCLASS wndclass; hInstMain = hInstance; // Register the frame window class wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = FrameWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_MAINFRAME)); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject(DKGRAY_BRUSH); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szFrameClass; if (!RegisterClass (&wndclass)) return 0; // Register the child window class wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wndclass.lpfnWndProc = ChildWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = sizeof (HANDLE); wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_CHILDFRAME)); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject (GRAY_BRUSH); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szChildClass; if (!RegisterClass (&wndclass)) return 0; // Obtain handles to three possible menus & submenus hMenuInit = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MAINFRAME)); hMenuChild = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CHILDFRAME)); hContextMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP)); hContextCombineMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_COMBINE)); hMenuInitWindow = GetSubMenu (hMenuInit, INIT_MENU_POS); hMenuChildWindow = GetSubMenu (hMenuChild, CHILD_MENU_POS); // Load accelerator table hAccel = LoadAccelerators (hInstance, MAKEINTRESOURCE(IDC_MAINACCEL)); // Create the frame window hwndFrame = CreateWindow(szFrameClass, TEXT ("LEADTOOLS MRC Segmentation Demo"), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuInit, hInstance, NULL); ShowWindow (hwndFrame, iCmdShow); UpdateWindow (hwndFrame); // Enter the modified message loop L_DlgInit(DLG_INIT_COLOR); while (GetMessage (&msg, NULL, 0, 0)) { if ((!TranslateMDISysAccel (hwndClient, &msg)) && (!TranslateAccelerator (hwndFrame, hAccel, &msg))) { TranslateMessage(&msg); DispatchMessage(&msg); } } L_DlgFree(); // Clean up by deleting unattached menus DestroyMenu(hMenuChild); DestroyMenu(hContextMenu); DestroyMenu(hContextCombineMenu); return msg.wParam; } L_BOOL CALLBACK CloseEnumProc (HWND hwnd, LPARAM lParam) { if (GetWindow (hwnd, GW_OWNER)) // Check for icon title return TRUE; SendMessage (GetParent (hwnd), WM_MDIRESTORE, (WPARAM) hwnd, 0); if (!SendMessage (hwnd, WM_QUERYENDSESSION, 0, 0)) return TRUE; SendMessage (GetParent (hwnd), WM_MDIDESTROY, (WPARAM) hwnd, 0); return TRUE; } L_INT DoDialogBoxParam(L_INT nDialog, HWND hWnd, DLGPROC pfnDialog, LPARAM lParam) { DLGPROC pfn; L_INT nRet; pfn = (DLGPROC) MakeProcInstance((FARPROC) pfnDialog, hInstMain); nRet = DialogBoxParam (hInstMain, MAKEINTRESOURCE (nDialog), hWnd, pfn, lParam); FreeProcInstance((FARPROC) pfn); return(nRet); } L_BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: { VERSIONINFO ver; L_TCHAR szBuffer[MAX_PATH]; L_VersionInfo (&ver,sizeof(ver)); wsprintf(szBuffer, TEXT("LEAD Product: %hs\nVersion %d.%d\nDate: %hs\nTime: %hs"), (L_TCHAR L_FAR *)ver.Product, ver.MajorNumber, ver.MinorNumber, (L_TCHAR L_FAR *)ver.Date, (L_TCHAR L_FAR *)ver.Time); SetWindowText(GetDlgItem(hDlg, IDC_STATIC_VERSIONINFO), szBuffer); return(TRUE); } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: EndDialog (hDlg, 0); return(TRUE); } } return(FALSE); }