April 30, 2024, 07:26:23 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Dialog from resource..??

Started by Ficko, November 15, 2008, 03:28:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ficko

November 15, 2008, 03:28:53 PM Last Edit: November 16, 2008, 07:26:55 AM by Ficko
I am trying to hook up a dialog or menu from resource but my solution is just horrifying to look at. ???
-Not even going to post it- ;D

Is there an â€Ã...“elegantâ€Ã, way to do it in EB.
Can’t find anything simile on the forum.
If somebody could refer me somewhere other than to â€Ã...“the hellâ€Ã, would be appreciated. ;)

I like to hook up a dialog and modify or add some more controls.

Pseudocode:

DEF D1:DIALOG
DEF CA[10]:STRING
D1 = LOADDIALOGFROMRESOURCE("MyD")
GETCONTROLS(D1,CA)
.
.
.
Use D1 and CA[n] -as controlidentifier- as usual.


Thanks,
Csaba

sapero

I'm waiting for this since 2000 :)
But there is a "winapi way" to use dialogsDialogBoxParam(_hInstance, IDD_DLG1, 0, &DlgProc, 0)

Ficko

Now you made me sad! :'( ;D

But your solution isn't that bad as mine so I take it thanks a lot! :D

Csaba

LarryMc

Sapero

I tried your example above.
The rc wouldn't compile until I deleted the "Font" line  at line 24 of the rc file.

Then when it did compile and I tried to run it it did not run....nothing....nada...

What I'm wanting to do is put a dialog in a resource file to use as a template to substitue for the standard choosefont or choosecolor dialog.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

Larry, the resource compiler (gorc.exe) from original Ebasic installation is very old and has bugs. The current version of resource maker (external resed.exe) outputs code for newer version of gorc, which in some cases is not backward compatible old gorc. You can download new gorc here: http://www.jorgon.freeserve.co.uk/ Current version is 0.90.5, and I'm still using 0.90.4 for Emergence and Aurora.

I have just downloaded and tried the newest version of gorc 90.5, it is working correctly with this example.
If you download it, rename your original gorc.exe in ebasic/bin directiry, and copy the new version. Update also the help file.

LarryMc

Thanks Sapero

Here's what I'm doing and it doesn't work.

I'm calling ChooseFontA to bring up the Font dialog and it works fine.

I'm wanting to substitute a different dialog for the font dialog.

I've added a dialog to the resource.  For testing I used one of yours that I changed the name of.
The first 2 lines are:
test DIALOGEX -2,-13,73,73
CAPTION "DTMF"


In my routine that calls ChooseFontA I have this:
string tpl
tpl="test"
cf.lpTemplateName=tpl


The standard Font dialog still opens as opposed to opening the "test" dialog in the resource file.

Can you do your magic?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

October 01, 2009, 06:54:34 AM #6 Last Edit: October 01, 2009, 07:00:49 AM by sapero
cf.lpTemplateName="test" ' can be assigned directly
cf.Flags =your flags | CF_ENABLETEMPLATE
cf.hInstance = _hinstance ' or GetModuleHandle("module with dialog resource.dll")

LPCTSTR lpTemplateName - if you see LPC - the optional C after LP is from "const", the data pointed to by this pointer will be not modified (with exception in CreateProcessW api)

The lpTemplateName can be also a numeric value (1, 2, ... 65535) if your dialog resource has a numeric identifier instead a "test" name.
_hinstance symbol is defined in windowssdk.inc as external integer, it is exported from ebasic core libraries. For gui-exe it is always equal to 0x400000. For console-exe it is (or at least was) not accessible without modifications in ebasic libs.

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

October 01, 2009, 05:58:13 PM #8 Last Edit: October 01, 2009, 06:22:12 PM by Larry McCaughn
OK,
I've got it where I call the system choosefont and substitute my dialog.

Now what I want to do is override the default choosefont's way of printing the entries in the Font combobox.
Everything else I want to work the standard way.

Don't know exactly how to do it other then I'm pretty sure I have to process MeasureItem and DrawItem for the listbox portion of the combobox.

I also think I need to use the lpfnHook to define the procedure to trap those messages to do my thing.

I'm just not sure how to set that up.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

October 02, 2009, 02:45:34 AM #9 Last Edit: October 02, 2009, 03:39:32 AM by sapero
This is a basic template:
$include "windowssdk.inc"
$include "commctrl.inc"
'$include "resource.inc"

$define FONT_DIALOG_RESOURCE_ID 401
$main

' if you did not opened ebasic window yet, call InitCommonControls
InitCommonControls()

CHOOSEFONT cf
LOGFONT    lf

cf.lStructSize = len(cf)
'cf.hwndOwner = GetForegroundWindow()
cf.lpLogFont = &lf
cf.Flags = CF_BOTH | CF_ENABLETEMPLATE | CF_ENABLEHOOK
cf.lpfnHook = &MyCFHookProc
cf.lpTemplateName = FONT_DIALOG_RESOURCE_ID
cf.hInstance = _hinstance

ChooseFont(&cf)


sub MyCFHookProc(HWND hdlg,UINT uiMsg,WPARAM wParam,LPARAM lParam),UINT_PTR
select (uiMsg)
case WM_INITDIALOG
'pointer pchoosefont = lParam
'settype pchoosefont,CHOOSEFONT
' cubclass controls here

case WM_CTLCOLORDLG
'return brush

case WM_DESTROY
' cleanup here

case WM_DRAWITEM
pointer pdis = &*<DRAWITEMSTRUCT>lParam
settype pdis, DRAWITEMSTRUCT
' wParam Specifies the identifier of the control
' *pdis.CtlType - ODT_BUTTON or ODT_COMBOBOX or ODT_LISTBOX or ODT_LISTVIEW or ODT_MENU or ODT_STATIC or ODT_TAB
' *pdis.itemID - item index
' *pdis.CtlID  - Specifies the identifier of the control
' *pdis.itemAction - ODA_DRAWENTIRE or ODA_FOCUS or ODA_SELECT
' *pdis.itemState  - ODS_CHECKED ODS_COMBOBOXEDIT ODS_DEFAULT ODS_DISABLED ODS_FOCUS ODS_GRAYED ODS_HOTLIGHT ODS_INACTIVE ODS_NOACCEL ODS_NOFOCUSRECT ODS_SELECTED
' *pdis.hwndItem   - Handle to the control
' *pdis.hDC        - Handle to a device context
' *pdis.rcItem     - Specifies a rectangle that defines the boundaries of the control to be drawn
' *pdis.itemData
if (*pdis.CtlType = ODT_COMBOBOX)
select (*pdis.CtlID)
case 1136 ' font      <- draw here, return nonzero to apply
int selIndex = _SendMessage(*pdis.hwndItem, CB_GETCURSEL, 0, 0)
if (selIndex <> CB_ERR)
int cchText = _SendMessage(*pdis.hwndItem, CB_GETLBTEXTLEN, selIndex, 0)
pointer pText = new(TCHAR, cchText+1)
' ...
else
' draw only the focus rectangle at the coordinates specified by the rcItem
if (!(*pdis.itemState & ODS_NOFOCUSRECT)) then DrawFocusRect(*pdis.hDC, *pdis.rcItem)
endif
case 1138 ' size
case 1139 ' color
case 1140 ' script
endselect
endif
endselect
' return zero to allow default processing
return 0
endsub

LarryMc

yet again, thanks Sapero!

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

OK,
I've made some progress but there is one small glitch that I have with one font.
The only way I know how to handle it is to trap and delete that font name from the combobox.

Attached is project and exe.

The font that is giving me fits is Cambria Math.
It displays properly in the standard dialog.
In the test template it does not display correctly when it is the selected font.

Run the exe and type cambria math in the edit field.
notice that after you have typed just cambia there is an entry for cambia followed by the blank line.
when you finish the name the cambria math text appears but it has leftover text to the right from other fonts.

Got any suggestions?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

Attached updated version with explanations. I do not have Cambria Math installed, but please check how does it draw now?

LarryMc

works much better, Sapero.

Thanks again!

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

October 03, 2009, 08:47:28 PM #14 Last Edit: October 03, 2009, 10:20:38 PM by Larry McCaughn
Sapero

just noticed
The underline, strikeout checkboxes are gone along with the groupbox that encloses them.
If I use the eba file I sent you they are there but if I use the eba file you sent back they are gone.
And that's using the same rc file in both cases.

Larry

FOUNDIT!!  The CF_EFFECTS flag was missing.  duh!

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Made a lot of progress so far.

I've added some of my own controls to the dialog.
I would like to implement the context-sensitive help when the controls are clicked with the right mouse the same way that the controls respond that are an integral part of the choosefont dialog when the CF_SHOWHELP flag is set.
The help pops up like a tooltip when controls are right clicked or F1 is pressed.

I'm assuming I have to fill the HELPINFO structure for each new control
After that I'm not sure how to set it up.
I think I need to trap WM_HELP and WM_CONTEXTHELP

Any example would be appreciated.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

October 05, 2009, 09:52:14 AM #16 Last Edit: October 06, 2009, 11:00:52 AM by sapero
Larry, I'm sure if you lookup WM_HELP message description, you'll see that it provides initialized HELPINFO structure. You only need to check if .iContextType is HELPINFO_WINDOW,  copy control ID from .iCtrlId or control handle from .hItemHandle and show a custom popup, a tooltip, call WinHelp (.hlp file needed) or fire the htmlhelp/mshelp2 engine.

WindowsÂÃ,® Server 2003 R2 Platform SDK
http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en
Old, small (400MB), fast and still very usefull download, a must-have.
Screenshot: http://i33.tinypic.com/2zgypf7.png

LarryMc

Thanks Sapero

I'm in the process of downloading it right now.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Ran into a snag.

All the info in the SDK uses a .hlp help file for context sensitive help and all I can create is .chm help files.

Anyone have a solution.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

I stumbled across the right combination of things that had to be in place in order for a dialog's context sensitive help to work with a .chm help file.

I've got some experimenting to do to make sure I get all the non-relevant code out of the way.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

I got the context-sensistive help to work using:
_HtmlHelp(*pHelp.hItemHandle, getstartpath+"fhelp.chm" ,HH_TP_HELP_WM_HELP, &hid)
provided the actual text file was the default CsHelp.txt.
If I used fhelp.txt of the name of the text file it said to use this format:
_HtmlHelp(*pHelp.hItemHandle, getstartpath+"fhelp.chm::fhelp.txt" ,HH_TP_HELP_WM_HELP, &hid)
that doesn't work
nor does "fhelp.chm fhelp.txt"
"fhelp.chm /fhelp.txt"
"fhelp.chm \fhelp.txt"
"fhelp.chm "getstartpath+"fhelp.txt"


Anyone know the correct syntax for identifying that non default txt file?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

That above does work.  I had my chm file and eba file out of sync.

When I get through with the little project I'm working on now I will do a little tutorial/demo on what all is involved in implementing contect help with text strings in dialogs.

And I'd never have gotten as far as I have without Sapero's help.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library