home *** CD-ROM | disk | FTP | other *** search
-
- SCRIPT TestDlg;
-
- #include "windows.inc"
-
- VAR hWndClient:Number;
- hRes,hToolBar,hMenu:Number;
-
- (*................................................*)
-
- FUNC TestDialog():Number;
-
- CONST IDD_TEXT0 = 200; (* IDs you assigned to dialog controls *)
- IDD_MYBUTTON = 201;
-
- IDD_TBFIRST = 250; (* IDs you assigned to toolbar buttons *)
- IDD_TBLAST = 253;
- IDD_TBHELP = 253;
-
- IDM_MENUFIRST = 1000; (* you MUST use this ID range for menu items *)
- IDM_MENULAST = 1199;
-
- IDM_ARRANGEICONS = 1033; (* A menu item we'll actually do something with *)
-
- VAR hDlg,iMsg,wParam,hStatus:Number;
- lParam:Long;
- myText:String[30];
- NumStr:String[10];
-
- BEGIN
- wParam := -1;
- myText := "A string to edit";
-
- (* Load the dialog template by name from the resource DLL (hRes) *)
- hDlg := LoadDialog(hRes, "TESTDLG",-1,-1);
- IF hDlg=0 THEN
- Write('Unable to find dialog template "TESTDLG".|');
- ELSE
- (* The dialog is automatically displayed, so now we are ready to
- * enter our message loop for this dialog.
- *)
- WHILE GetDialogMessage(hDlg,iMsg,wParam,lParam) DO
- CASE iMsg OF (* check message type *)
- | WM_INITDIALOG:
- (* This is the first msg every dialog gets. It tells us
- * to fill in all the text controls, highlight the
- * appropriate radio buttons etc.
- *)
- SetDlgItemText(hDlg,IDD_TEXT0,myText);
- hStatus := AssignStatus(hDlg, "[20]TESTDLG.SCR[0]Demonstration Status Line");
- AssignMenu(hDlg, hMenu, 3);
- AssignToolBar(hDlg, hToolBar);
-
- | WM_COMMAND:
- (* You get a WM_COMMAND message every time the user clicks
- * a menu item, toolbar button or a button in the dialog,
- * in which case wParam identifies the item. You also
- * get WM_COMMANDs which are actually notification messages
- * from listbox controls and the like.
- *)
- IF ((wParam>=IDM_MENUFIRST) AND (wParam<=IDM_MENULAST)) THEN
- IntToStr(wParam, NumStr);
- SetStatusField(hStatus, 1, "Menu command ("+NumStr+") selected.");
- IF wParam=IDM_ARRANGEICONS THEN
- WinPostMessage(hWndClient,WM_MDIICONARRANGE,0,0);
- END;
- ELSIF ((wParam>=IDD_TBFIRST) AND (wParam<=IDD_TBLAST)) THEN
- IntToStr(wParam-IDD_TBFIRST, NumStr);
- SetStatusField(hStatus, 1, "ToolBar button("+NumStr+") clicked.");
- IF wParam=IDD_TBHELP THEN
- WinPostMessage(hDlg,WM_COMMAND,IDHELP,0);
- END;
- ELSE
- CASE wParam OF
- | IDD_MYBUTTON:
- SetDlgItemText(hDlg, IDD_TEXT0, "Button clicked!");
- SetStatusField(hStatus, 1, "Button clicked!");
- | IDHELP:
- MessageBox(GetFocus(),
- "Sorry, this demo doesn't provide any help!",
- "Help!",
- MB_ICONSTOP+MB_OK);
- | IDOK:
- (* OK button clicked - read out the final values
- * of the dialog fields, then close the dialog.
- *)
- GetDlgItemText(hDlg, IDD_TEXT0, myText);
- EndDialog(hDlg, 1);
- | IDCANCEL:
- (* Cancel button clicked - discard any changes
- * made to dialog fields, then close the dialog.
- *)
- EndDialog(hDlg, 0);
- END;
- END;
- END;
- END;
- END;
- Write("Dialog has ended, result=",wParam,".|");
- Write(' string was "',myText,'".|');
- return wParam;
- END;
-
- (*................................................*)
-
- BEGIN
- (* This next line shows a trick you can use to obtain the handle of
- * Odyssey's MDI client window. This is a standard windows which all
- * genuine MDI applications have. The Windows Programmers Reference
- * books documents messages you can send to Windows of this type. For
- * the purpose of this demo we will only be sending a WM_MDIICONARRANGE
- * message to it.
- *)
- hWndClient := GetDlgItem(GetOdyWindow(), 0);
-
- (* We need a handle to the library (DLL) where our resources
- * are stored (ie. menu and dialog templates, toolbar bitmaps, etc.
- *)
- hRes := LoadResourceLibrary("demodlg.dll");
-
- IF (hRes>=32) THEN (* make sure the resource DLL handle is valid *)
- (* Extract a menu template by name from the resource library *)
- hMenu := LoadMenu(hRes, "TEST_MENU");
-
- IF hMenu<>0 THEN (* if that worked, then... *)
- (* Tell Odyssey to extract a toolbar bitmap from the resource
- * DLL, and turn it into an actual toolbar.
- *)
- hToolBar := CreateToolBar(hRes,"TEST_TOOLS",4,
- "250[Button help0],251[Button help1],252[Button help2],253[Button help3]");
-
- (* Note that by this point the menu and toolbar objects are
- * loaded, but so far they are neither visible nor active. That
- * is because they are only displayed when the associated
- * modeless dialog is active, and we haven't even created that
- * dialog next - the following local function both creates (loads)
- * and animates the dialog.
- *)
- TestDialog();
-
- (* If we've finished animating the dialog then we are finished
- * altogether, which means that now we might as well free the
- * resources we allocated above.
- *)
- DestroyToolBar(hToolBar);
- DestroyMenu(hMenu);
- (* Note that the hToolBar and hMenu handles are invalid from
- * this point onwards.
- *)
- END;
-
- (* Finally, we tell Windows to discard the resource DLL *)
- FreeResourceLibrary(hRes);
-
- (* Fini. *)
- ELSE
- (* Well, that didn't get very far, did it! *)
- Write('Unable to open resource library "DEMODLG.DLL".|');
- END;
- END;
-
-