Better working version now:
I would recommend to remove the assigned ControlIDs and leave the enumeration to tB - but Max insists to keep these
Edit- attachement 2 posts below...
Thanks Maxer73 for pushing the idea.
EDIT: Below was a script that "translates" .RC-files as written with this editor (ResEd) (there are certainly others) to TB-code. Now it's attached one post below this
You just run this script, load some .rc-file when prompted- thereafter you have code on clipboard and can insert to thinAir.
The generated code is supposed to be a .tBasicU-file but can be tested also as .tBasic-File when uncommenting the marked line in the beginning.
PS.: I really hope the tB-Equate %WS_Child equals Win32ish WS_ChildWindow and its a little messed up with those font-styles - style means bold, underline italic and the third I'm not sure about.
Somehow it's still buggy and I don't have the powers to delete the thread nor the idea how to fix it yet. Maybe someone else comes up with something better....
Last edited by ReneMiner; 14-10-2013 at 15:54.
I think there are missing some Forum-sections as beta-testing and support
Better working version now:
I would recommend to remove the assigned ControlIDs and leave the enumeration to tB - but Max insists to keep these
Edit- attachement 2 posts below...
Last edited by ReneMiner; 14-10-2013 at 17:06.
I think there are missing some Forum-sections as beta-testing and support
Rene,
There's a bad link to your file.
Bill
No- i just updated it - probably same moment when you tried to download it
In the generated code you'll find something like
for better understanding: if it reads like this:'... DWord IDD_DLG1 ' uncomment following to test ' IDD_DLG1 = IDD_DLG1_StartUp(0) ' Dialog Show Modal IDD_DLG1
you have a stand-alone .tBasic-script to test-run it. Intentionally it's supposed to be a tBasicU-code-unit so the UI-setup can be easily exchanged when the layout changes or another dialog gets added to the project.'... DWord IDD_DLG1 IDD_DLG1 = IDD_DLG1_StartUp(0) Dialog Show Modal IDD_DLG1
Edit: attachement removed- see below
Last edited by ReneMiner; 17-10-2013 at 14:24.
I think there are missing some Forum-sections as beta-testing and support
Thanks, Rene.
Bill
I made a little new version:
It now creates also a TBMain-function and a simple skeleton for callbacks.
If using more than one dialog the first one becomes the parent of the following, but you can change this as you like.
Also a bit of cosmetics so you get now a time/date and resource-information into the code.
Edit : attachement removed - see further below
Last edited by ReneMiner; 17-10-2013 at 14:23.
I think there are missing some Forum-sections as beta-testing and support
Thank you Rene,
works good on my testing samples!
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
A new version again:
Now it also creates dialog-menus. But there seems to be a problem with ACCEL ATTACH -method.
I tried different ways but it does not attach the accelerator-keys to the menu.
Anyway- the script creates the code also for the Accel-Keys (they just don't work - but I think that's not my fault) - maybe someone has some hint for me why it does not attach the Accel-Keys to controls nor menuitems.
Also there might be other visual editors than Resed, that save Menu-Flags in different way - I saw for example some strange "0x00008000" in a few rc-files that Maxer73 sent me - these do not work with tokenizer - it makes one numeral (0) and one string of it ("x00008000") - so two tokens from one expression -
I sticked to Resed-syntax here which reads like "GRAYED" and "CHECKED" for menu-flags. Other hex-values for styles & ex-styles are valid - but not for menu
Another point:
Resed saves rc-files even if controls have no IDs or IDs are not unique. So you have to be very attentive and check yourself that every dialog, control and menuItem has its unique, valid ID. IDs (i.e. constants in the created tB-code) ending with underscore seem to create some hiccups so better check IDs twice.
EDIT:
Also the created script has in front a few more windows-constants that I've found not available in UI - but I think there are a few still missing.
You can remove these of course if they are not used in your script. If you come across some unknown equate - I've found a page that lists them - use the search-function there and type in the equate, select the first suggested then and find the value on top there.Begin Const %WS_EX_DLGMODALFRAME = &H00000001 %ES_VERTICAL = &H00400000 %WS_CHILDWINDOW = %WS_CHILD %WS_SIZEBOX = &H00040000 %DS_FixedSys = &H00000008 %DS_ShellFont = %DS_FixedSys | %DS_SETFONT %LWS_TRANSPARENT = &H00000001 %PGS_HORZ = &H00000001 %SS_ICON = &H00000003 %HDS_BUTTONS = &H00000002 End Const
...the attachement one post below now
Last edited by ReneMiner; 17-10-2013 at 13:47.
I think there are missing some Forum-sections as beta-testing and support
Maxer urged me to rewrite this. Anyway I've found a bug if control-id's are not ucase$ (fixed) and another one that occured because - (minus) was not treated as part of numeric expression. Now this has a small dialog in the beginning (created with resed and translated by itself) so you can specify in advance what parts of code you want to have created.
Still unsolved mystery is the accell attach that seems not to do anything...
Attachement futher below now...
Last edited by ReneMiner; 17-10-2013 at 17:59.
I think there are missing some Forum-sections as beta-testing and support
Accel Attach issue solved:
It works only if the dialog has focus - but not if one of the controls has focus.
This is some created testing script, I only modified the callback to end on CTRL+E for a test.
Edit:Uses "UI" ' code created from .rc-file ' C:\<path removed>\DialogMenu(1).rc ' 2013-10-17 16:56:56 Begin ControlID %IDC_EDT1 ' = 1002 %IDC_CBE1 ' = 1001 %IDM_OPEN ' = 10002 %IDM_SAVE ' = 10003 %IDM_EXIT ' = 10005 %IDM_OPENPDF ' = 10008 %IDM_ABOUT ' = 10007 End ControlID Begin Const %WS_EX_DLGMODALFRAME = &H00000001 %ES_VERTICAL = &H00400000 %WS_CHILDWINDOW = %WS_CHILD %WS_SIZEBOX = &H00040000 %DS_FIXEDSYS = &H00000008 %DS_SHELLFONT = %DS_FIXEDSYS | %DS_SETFONT %LWS_TRANSPARENT = &H00000001 %PGS_HORZ = &H00000001 %SS_ICON = &H00000003 %HDS_BUTTONS = &H00000002 End Const Boolean keepRunning = TRUE DWord IDD_DLG1 ' - - - - - - - - - - - - - - - - - - - - Function IDD_DLG1_StartUp(ByVal hParent As DWord) As DWord DWord hDlg, hFont, hMenu MENU New Bar To hMenu DWord hPopUp_001 MENU New Popup To hPopup_001 MENU Add Popup, hMenu, "&File", hPopup_001, %MF_ENABLED MENU Add String, hPopup_001, "&Open", %IDM_OPEN, %MF_ENABLED MENU Add String, hPopup_001, "&Save", %IDM_SAVE, %MF_ENABLED MENU Add String, hPopup_001, "-", 0, 0 MENU Add String, hPopup_001, "&Exit", %IDM_EXIT, %MF_ENABLED DWord hPopUp_002 MENU New Popup To hPopup_002 MENU Add Popup, hMenu, "&Help", hPopup_002, %MF_ENABLED MENU Add String, hPopup_002, "&Open PDF Help", %IDM_OPENPDF, %MF_ENABLED MENU Add String, hPopup_002, "&About", %IDM_ABOUT, %MF_ENABLED hDlg = Dialog New hParent, "IDD_DLG1", 0,0,336,207, %WS_VISIBLE | %WS_OVERLAPPEDWINDOW | %DS_CENTER hFont = Font_Create("MS Sans Serif", 8) Dialog Send hDlg, %WM_SETFONT, hFont, 0 Control Add "Edit", hDlg, %IDC_EDT1, "", 177, 141, 81, 12, %WS_CHILDWINDOW | %WS_VISIBLE | %WS_TABSTOP, %WS_EX_CLIENTEDGE Control Add "ComboBoxEx32", hDlg, %IDC_CBE1, "", 135, 39, 129, 105, %WS_CHILDWINDOW | %WS_VISIBLE | %WS_TABSTOP | &H00000003 MENU Attach hMenu, hDlg Local AccelTable(4) As ACCELAPI DWord hAccel AccelTable(1).fvirt = %FVIRTKEY Or %FCONTROL AccelTable(1).key = %VK_O AccelTable(1).cmd = %IDM_OPEN AccelTable(2).fvirt = %FVIRTKEY Or %FCONTROL AccelTable(2).key = %VK_S AccelTable(2).cmd = %IDM_SAVE AccelTable(3).fvirt = %FVIRTKEY Or %FCONTROL AccelTable(3).key = %VK_E AccelTable(3).cmd = %IDM_EXIT AccelTable(4).fvirt = %FVIRTKEY Or %FCONTROL AccelTable(4).key = %VK_A AccelTable(4).cmd = %IDM_ABOUT ACCEL Attach hDlg, AccelTable() To hAccel Function = hDlg End Function ' - - - - - - - - - - - - - - - - - - - - CallBack Function IDD_DLG1_Callback() Select Case CBMSG Case %WM_INITDIALOG ' -- Put code to be executed after dialog creation here Case %WM_COMMAND ' -- You can handle controls here Select Case CBCTL Case %IDC_EDT1 Case %IDC_CBE1 Case %IDM_OPEN Case %IDM_SAVE Case %IDM_EXIT keepRunning = FALSE Case %IDM_OPENPDF Case %IDM_ABOUT End Select Case %WM_SYSCOMMAND Case %WM_CLOSE ' -- Put code to be executed before dialog end here keepRunning = FALSE End Select End Function ' -------------------------------------------------- Function TBMain() Long numberOfDialogsAlive IDD_DLG1 = IDD_DLG1_StartUp(%HWND_DESKTOP) Dialog Show Modeless IDD_DLG1 Call IDD_DLG1_Callback While keepRunning Dialog DoEvents To NumberOfDialogsAlive Wend End Function
Now takes also those "0x00000003" & "0x00000008" -flags for menuitems
see next page for the file
Last edited by ReneMiner; 19-10-2013 at 18:03.
I think there are missing some Forum-sections as beta-testing and support
Bookmarks