1. Jury-rigged dialogs
- Posted by Michael Sabal <mjs at OSA.ATT.NE.JP> Jun 03, 1998
- 644 views
- Last edited Jun 04, 1998
If anybody cares, my line's fixed, so I'm back on-line. During the = weekend of limited email, I was able to jury-rig a pretty good dialog = box. Basically, here are the problems and usable solutions. 1) To create the dialog, it must be defined without parents and use the = modal-attribute WS_DLGFRAME. 2) LText defines labels (so far, I haven't been able to format the = font/color of these labels. Maybe someone else has an idea?) 3) Input fields are defined with EditText. To find out what the user = typed, use GetText(inputField). To set a default response, use = SetText(inputField). To make a field non-editable (perhaps for viewing = records or setting an index number), use SetEnable(inputField,0). To = release it, use SetEnable(inputField,1). 4) Buttons work perfectly fine in the dialog box, but they are the only = way to properly make the dialog go away. The funky little 'X' in the = upper-right hand corner doesn't work. =20 5) If you use closeWindow or unloadWindow, there are some undesirable = effects (i.e. minimizes the window instead of destroying or quits your = application). While this isn't the best solution, it works: set a = usage flag for the dialog. I use -1 for never used, 0 for used but = finished, and 1+ for currently in use. If my dialog loses focus and I = try to use the menus to reopen it, the program crashes. So when I = choose the menu function, I check the flag to see if it's already open. = If the flag is 1+, I do nothing. If it's -1, I use loadWindow. If it's = 0, I use setVisible(dialog,1). To close the dialog, use = setVisible(dialog,0). If you don't want the data to remain in the = dialog, call a procedure that sets all field values to "". While this isn't an ideal setup, it does allow me to do what I want to, = and infinitely faster than I could do it in Java. The code that follows = is only the skeleton of the final project, so any comments or = suggestions would be well-received. [Tested code follows], Michael J. Sabal mjs at osa.att.ne.jp http://home.att.ne.jp/gold/mjs/ with trace -- TSI Store Manager - Euphoria version 0.1 -- Written by Michael J. Sabal -- on May 11, 1998 -- This Windoze program will allow users to keep track of sales and = inventory -- data for multiple branches. include win32lib.ew include get.e -- setup controls for main window constant primWin =3D create(Window,"TSI Store Manager (Euphoria) - v. = 0.1", 0,10,10,500,350,0) constant fileMenu =3D definePopup(primWin, "&File") constant filePageSetup =3D definePopupItem(fileMenu, "Page &Setup") constant filePrint =3D definePopupItem(fileMenu,"&Print") constant filePreferences =3D definePopupItem(fileMenu,"Pre&ferences") constant filePasswords =3D definePopupItem(fileMenu,"Pass&words") constant fileSep1 =3D definePopupItem(fileMenu,"-") constant fileExit =3D definePopupItem(fileMenu,"&Exit") constant reportMenu =3D definePopup(primWin, "&Reports") constant reportDailySales =3D definePopupItem(reportMenu,"&Daily Sales = Report") constant reportMonthlySales =3D definePopupItem(reportMenu, "&Monthly Sales Report") constant reportWarehouse =3D definePopupItem(reportMenu,"&Warehouse = Report") constant reportCustomer =3D definePopupItem(reportMenu,"&Customer = Report") constant reportManager =3D definePopupItem(reportMenu,"Manager\'s = &Report") constant salesMenu =3D definePopup(primWin, "&Sales") constant salesNewOrder =3D definePopupItem(salesMenu,"&New Order") constant salesChangeOrder =3D definePopupItem(salesMenu,"C&hange = Order") constant salesCancelOrder =3D definePopupItem(salesMenu,"&Cancel = Order") constant salesVoidOrder =3D definePopupItem(salesMenu,"&Void Order") constant salesSep1 =3D definePopupItem(salesMenu,"-") constant salesSettleUp =3D definePopupItem(salesMenu,"&Settle up") constant customerMenu =3D definePopup(primWin, "&Customer") constant customerNew =3D definePopupItem(customerMenu,"&New customer") constant customerEdit =3D definePopupItem(customerMenu,"&Edit = customer") constant customerView =3D definePopupItem(customerMenu,"&View = customer") constant customerDelete =3D definePopupItem(customerMenu,"&Delete = customer") constant warehouseMenu =3D definePopup(primWin, "&Warehouse") constant warehouseSearch =3D definePopupItem(warehouseMenu,"Searc&h = warehouse") constant warehouseSep1 =3D definePopupItem(warehouseMenu,"-") constant warehouseProductAdd =3D definePopupItem(warehouseMenu, "Product &Add") constant warehouseProductEdit =3D definePopupItem(warehouseMenu, "Product &Edit") constant warehouseProductDelete =3D definePopupItem(warehouseMenu, "Product &Delete") constant warehouseSep2 =3D definePopupItem(warehouseMenu,"-") constant warehousePONew =3D definePopupItem(warehouseMenu,"PO &New") constant warehousePOEdit =3D definePopupItem(warehouseMenu,"P&O Edit") constant warehousePOCancel =3D definePopupItem(warehouseMenu,"PO = &Cancel") constant warehousePOReceive =3D definePopupItem(warehouseMenu,"PO = &Receive") constant warehouseSep3 =3D definePopupItem(warehouseMenu,"-") constant warehouseVendorAdd =3D definePopupItem(warehouseMenu,"&Vendor = Add") constant warehouseVendorEdit =3D definePopupItem(warehouseMenu,"Vendor = Edi&t") constant warehouseVendorDelete =3D definePopupItem(warehouseMenu, "Vendor De&lete") constant warehouseSep4 =3D definePopupItem(warehouseMenu,"-") constant warehousePhysInv =3D definePopupItem(warehouseMenu, "Physical &Inventory") constant warehouseUnitLoc =3D definePopupItem(warehouseMenu, "&Set Item Location") constant warehouseAlloc =3D definePopupItem(warehouseMenu,"Allocate = &unit") constant warehouseRecalc =3D definePopupItem(warehouseMenu, "&Fix Product Totals") constant helpMenu =3D definePopup(primWin, "&Help") constant helpAbout =3D definePopupItem(helpMenu,"&About") constant helpCredits =3D definePopupItem(helpMenu,"&Credits") constant helpSmart =3D definePopupItem(helpMenu,"&Smart help") constant helpIndex =3D definePopupItem(helpMenu,"&Index") =20 -- setup controls for Customer Dialog Box constant XFONT =3D 8, YFONT =3D 19, EDITFLUSH =3D XFONT*10 constant customerDialog =3D create(Window,"Customers",0,15,15, 425,265,WS_DLGFRAME) constant cdIDLabel =3D create(LText,"Cust. ID",customerDialog,1,1, XFONT*9,YFONT,0) constant cdID =3D create(EditText,"",customerDialog,EDITFLUSH,1, XFONT*8,YFONT-1,0) constant cdLastNameLabel =3D create(LText,"Last name",customerDialog,1, YFONT+1,XFONT*10,YFONT,0) constant cdLastName =3D = XFONT*30,YFONT-1,0) constant cdFirstNameLabel =3D create(LText,"First = name",customerDialog,1, YFONT*2+1,XFONT*11,YFONT,0) constant cdFirstName =3D = XFONT*30,YFONT-1,0) constant cdAddressLabel =3D create(LText,"Address",customerDialog,1, YFONT*3+1,XFONT*8,YFONT,0) constant cdAddress1 =3D = XFONT*40,YFONT-1,0) constant cdAddress2 =3D = XFONT*40,YFONT-1,0) constant cdCityLabel =3D = create(LText,"City",customerDialog,1,YFONT*5+1, XFONT*5,YFONT-1,0) constant cdCity =3D = XFONT*15,YFONT-1,0) constant cdStateLabel =3D = YFONT*5+1,XFONT,YFONT-1,0) constant cdState =3D = YFONT*5+1,XFONT*5,YFONT-1,0) constant cdZipLabel =3D create(LText,"Zip",customerDialog, EDITFLUSH+(XFONT*22),YFONT*5+1,XFONT*4,YFONT-1,0) constant cdZip =3D = YFONT*5+1,XFONT*10,YFONT-1,0) constant cdPhoneLabel =3D = create(LText,"Phone",customerDialog,1,YFONT*6+1, XFONT*6,YFONT-1,0) constant cdPhone =3D = XFONT*20,YFONT-1,0) constant cdFaxLabel =3D create(LText,"Fax", customerDialog,1,YFONT*7+1, XFONT*4,YFONT-1,0) constant cdFax =3D = XFONT*20,YFONT-1,0) constant cdEmailLabel =3D = create(LText,"E-mail",customerDialog,1,YFONT*8+1, XFONT*7,YFONT-1,0) constant cdEmail =3D = XFONT*30,YFONT-1,0) constant cdBalanceLabel =3D = XFONT*8,YFONT-1,0) constant cdBalance =3D = XFONT*10,YFONT-1,0) constant cdPrev =3D = XFONT*6,YFONT,0) constant cdNext =3D = XFONT*6,YFONT,0) constant cdOK =3D = XFONT*6,YFONT,0) constant cdClear =3D = XFONT*6,YFONT,0) constant cdCancel =3D = YFONT*11,XFONT*7,YFONT,0) -- PROGRAM VARIABLES sequence db_customer atom cdFlag db_customer =3D {} cdFlag =3D -1 -- PROCEDURES & FUNCTIONS procedure doCustomerDialog(object WinBack, object TextFore, object = TextBack) -- this isn't exactly working the way I'd like, maybe it's a problem -- with win32lib or I'm doing something wrong. But I'll try to = clean -- it up later. if cdFlag =3D -1 then loadWindow(customerDialog) else setVisible(customerDialog,1) end if setWindowBackColor(customerDialog,WinBack) setFont(customerDialog,"Times New Roman",12,Bold) setBackColor(customerDialog,TextBack) end procedure -- FILE MENU procedure onMenu_fileExit() unloadWindow(primWin) end procedure -- REPORT MENU -- SALES MENU -- CUSTOMER MENU =20 -- customer dialog functions function cdCapture() object temp sequence ret ret =3D {} =20 temp =3D value(getText(cdID)) if temp[1] =3D GET_SUCCESS then ret =3D append(ret,temp[2]) else ret =3D append(ret,-1) end if ret =3D append(ret,getText(cdLastName)) ret =3D append(ret,getText(cdFirstName)) ret =3D append(ret,getText(cdAddress1)) ret =3D append(ret,getText(cdAddress2)) ret =3D append(ret,getText(cdCity)) ret =3D append(ret,getText(cdState)) ret =3D append(ret,getText(cdZip)) ret =3D append(ret,getText(cdPhone)) ret =3D append(ret,getText(cdFax)) ret =3D append(ret,getText(cdEmail)) temp =3D value(getText(cdBalance)) if temp[1] =3D GET_SUCCESS then ret =3D append(ret,temp[2]) else ret =3D append(ret,0) end if return ret end function procedure cdReset() =20 setText(cdID,"") setText(cdLastName,"") setText(cdFirstName,"") setText(cdAddress1,"") setText(cdAddress2,"") setText(cdCity,"") setText(cdState,"") setText(cdZip,"") setText(cdPhone,"") setText(cdFax,"") setText(cdEmail,"") setText(cdBalance,"") =20 end procedure procedure onClick_cdOK(integer X, integer Y) -- Note1: in win32lib:a10, unloadWindow =3D close application -- Note2: in win32lib:a10, closeWindow =3D minimize window -- So, patch in a hide window & reshow it later sequence cdData =20 if cdFlag =3D 1 then db_customer =3D append(db_customer,cdCapture()) cdReset() elsif cdFlag =3D 2 then =20 elsif cdFlag =3D 3 then =20 elsif cdFlag =3D 4 then =20 end if =20 setVisible(customerDialog,0) cdFlag =3D 0 end procedure=20 -- customer menu hooks procedure onMenu_customerNew() =20 atom newID =20 if length(db_customer) =3D 0 then newID =3D 0 else newID =3D db_customer[length(db_customer)][1] end if newID =3D newID + 1 =20 if cdFlag < 1 then doCustomerDialog(getSysColor(COLOR_BTNFACE),rgb(#FF,#FF,0), getSysColor(COLOR_BTNFACE)) setText(cdID,sprintf("%d",newID)) setEnable(cdID,0) setEnable(cdBalance,0) cdFlag =3D 1 end if end procedure procedure onMenu_customerEdit() if cdFlag < 1 then doCustomerDialog(getSysColor(COLOR_BTNFACE),rgb(#FF,#FF,0), getSysColor(COLOR_BTNFACE)) cdFlag =3D 2 end if end procedure procedure onMenu_customerDelete() if cdFlag < 1 then doCustomerDialog(getSysColor(COLOR_BTNFACE),rgb(#FF,#FF,0), getSysColor(COLOR_BTNFACE)) cdFlag =3D 3 end if end procedure procedure onMenu_customerView() if cdFlag < 1 then doCustomerDialog(getSysColor(COLOR_BTNFACE),rgb(#FF,#FF,0), getSysColor(COLOR_BTNFACE)) cdFlag =3D 4 end if end procedure -- WAREHOUSE MENU -- HELP MENU -- WINDOW ACTIONS procedure onResize_PrimWin(integer sizeX, integer sizeY) -- so far nothing happens in resize, but when reports are added, we'll -- need this. end procedure procedure onLoad_PrimWin() -- as of May 12, 1998, this set of commands has no effect due to a -- problem with David Cuny's Win32Lib =20 -- disable file menu items enableMenuItem(filePageSetup, 0) enableMenuItem(filePrint,0) enableMenuItem(filePreferences,0) enableMenuItem(filePasswords,0) -- disable report menu items enableMenuItem(reportDailySales,0) enableMenuItem(reportMonthlySales,0) enableMenuItem(reportCustomer,0) enableMenuItem(reportWarehouse,0) enableMenuItem(reportManager,0) -- disable sales menu items enableMenuItem(salesNewOrder,0) enableMenuItem(salesChangeOrder,0) enableMenuItem(salesCancelOrder,0) enableMenuItem(salesVoidOrder,0) -- disable customer menu items enableMenuItem(customerEdit,0) enableMenuItem(customerDelete,0) enableMenuItem(customerView,0) -- disable warehouse menu items enableMenuItem(warehouseSearch,0) enableMenuItem(warehouseProductAdd,0) enableMenuItem(warehouseProductEdit,0) enableMenuItem(warehouseProductDelete,0) enableMenuItem(warehousePONew,0) enableMenuItem(warehousePOEdit,0) enableMenuItem(warehousePOCancel,0) enableMenuItem(warehousePOReceive,0) enableMenuItem(warehouseVendorAdd,0) enableMenuItem(warehouseVendorEdit,0) enableMenuItem(warehouseVendorDelete,0) enableMenuItem(warehousePhysInv,0) enableMenuItem(warehouseUnitLoc,0) enableMenuItem(warehouseAlloc,0) enableMenuItem(warehouseRecalc,0) -- disable help menu items enableMenuItem(helpAbout,0) enableMenuItem(helpCredits,0) enableMenuItem(helpSmart,0) enableMenuItem(helpIndex,0) end procedure -- FINAL DEFINITIONS onMenu[fileExit] =3D routine_id("onMenu_fileExit") onMenu[customerNew] =3D routine_id("onMenu_customerNew") onMenu[customerEdit] =3D routine_id("onMenu_customerEdit") onMenu[customerDelete] =3D routine_id("onMenu_customerDelete") onMenu[customerView] =3D routine_id("onMenu_customerView") onClick[cdOK] =3D routine_id("onClick_cdOK") onResize[primWin] =3D routine_id("onResize_PrimWin") onLoad[primWin] =3D routine_id("onLoad_PrimWin") WinMain(primWin)
2. Re: Jury-rigged dialogs
- Posted by David Cuny <dcuny at DSS.CA.GOV> Jun 04, 1998
- 608 views
Michael Sabal wrote: >> ... During the weekend of >>limited email, I was able to jury-rig a pretty good dialog box. Thanks for the code. Unfortunately, the window isn't modal - you can = still focus on the parent window while the "dialog" is open. Jacques sent me some "real" dialog code I hope to take a look at this = weekend. If I can't hack a normal window into acting modal (and it = doesn't look promising), I'll implement "real" dialogs in Win32Lib. -- David Cuny