Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog Menu - Match Background App
#1
Hi Gintaras,
I am using the menu's in a dialog (see example below from a different post) which I am hanging on another app window. I would like to be able to make the background of the menu match the parent application better - either by specifying the color or making transparent like the menu. I have been going through the different styles but without success. Any advice?
Thanks a million, as always!
Stuart

Function DialogWithMenu
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str rea3
if(!ShowDialog("DialogWithMenu" &DialogWithMenu &controls 0 0 0 0 0 0 0 "dialog.ico" "DialogWithMenu")) ret

;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 294 190 "Dialog"
;3 RichEdit20A 0x54233044 0x101 0 0 294 190 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020009 "*" ""

ret
;messages
sel message
,case WM_INITDIALOG
,
,case WM_SIZE
,RECT r; GetClientRect(hDlg &r)
,siz r.right r.bottom id(3 hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,;menu items:
,case 101    ;; Menu File>>Open
,,str s fileTxt
,,if OpenSaveDialog(0 s "Text files[]*.txt[]Image files[]*.bmp;*.gif[]All Files[]*.*[]")
,,,fileTxt.getfile(s)
,,,fileTxt.setwintext(id(3 hDlg))
,case 103 out "Cut"
,case 104 out "Select All"
,case 105 out "Help"
,case 106 SendMessage(id(3 hDlg) WM_UNDO 0 0)
,case 110 ;;Enable Undo
,int hm=GetMenu(hDlg) ;;menu bar
,EnableMenuItem hm 106 0
,case 111 ;;Disable Undo
,hm=GetMenu(hDlg) ;;menu bar
,EnableMenuItem hm 106 MF_GRAYED
ret 1

;BEGIN MENU
;>&File
,;&Open : 101 0 0 Co
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit
,;&Undo : 106 0 1 Cz
,;Enable Undo : 110
,;Disable Undo : 111
,;Cu&t : 103 0 0 Cx
,;-
,;Select &All : 104 0 0 Ca
,;<
;&Help : 105 0
;END MENU
#2
Silly me -- I realized that I can do the same thing by using the transparent background function of a toolbar and hanging my dialog material on as a hook.
Anyway, if it is easy to do what I was inquiring about in the prior that's great otherwise I can make do as above.

Thanks,
Stuart
#3
Quote:I would like to be able to make the background of the menu match the parent application better - either by specifying the color or making transparent like the menu.

I don't understand this. To change dialog color, process WM_CTLCOLORDLG message. To change menu color, use ownerdraw menu, which is quite difficult.
#4
You are right. I think I was trying to change the menu color not the dialog color. Since that is too complicated, I will instead make bmp's for dlg buttons that match the buttons on the parent application.
Using even simple PAINT program, I can match the background color gradient behind each button of the parent application and use similar icons as parent application, similar font, etc.
This works out quite well except for a couple small things:

When I use the code below in WM_INITDIALOG to place the button image, I lose the hover-over effect that normal dialog buttons have.
Code:
Copy      Help
,,SendMessage(id(3 hDlg) BM_SETIMAGE IMAGE_BITMAP LoadPictureFile(":200 ButtonImage.bmp" 0)) ;;can be bmp, gif of jpg
,,

Is it possible to have a different image be swapped over the button when it is hovered-over? That way, I can match the hover-over behavior/appearance of the buttons in the parent application.

Also, can't quite get the "3D edge" on the button. I want it ideally to be seamless with the background so I can match it better to the host app.


Thanks for helping with such picky points!!!,
Stuart
#5
Cannot answer, need learning and experimenting. Maybe I'll have some ideas if you post host app screenshot.
#6
Thanks. I will try and get this to you soon.
Stuart
#7
I have attached two images:
The first is the menu buttons without any cursor hover-over
The second is with the cursor hovering over the Open menu choice.
The cursor doesn't display in the screen capture but it is there causing the color change.
I could make a jpg that mimicked both states and then swap them out on hover-over.

       

Thanks!!!
Stuart
#8
Solution 1 - on the web find a component that can display such toolbars. But they usually are too big, expensive, may not work with QM, may not look exactly as you want.
Solution 2 - completely draw everything yourself. Can try ToolbarWindow32, but I'm not sure that you can draw it completely. Or use multiple ownerdraw Button controls. Or create your control class and draw it completely. If you want to draw standard menu bar, it is also possible. In any case, much much work.
#9
I think I see the problem and think I have an alternative solution.
Looking in http://www.quickmacros.com/forum/showthread.php?tid=832,
I found the DT_TbAddButtons function for adding icons from dlls to ToolbarWindow32. Using a Dll Icon viewer (icon seizer), I was able to look through and choose from 100s (maybe 1000s) of icons in my system_32 folder.

For my purposes, I don't need to match the hover over behavior EXACTLY, I just wanted SOME hover-over behavior, so that the user knows he has activated the button. I also wanted my own text on the button, which I am able to do with the DT_TbAddButtons function.

I did try adding my own images into the icon bmps like "de_ctrl.bmp" but (as you wrote above!!!), this seemed a little too hard.

So I think I have a working soluiton. My only question now, is that is is really true that there is no way to have a "notify" like style on a button that one has placed their own bmp on.
Not swapping it with another bmp, just having a frame appear around it on hover, or whatever the automatic "notify" behavior is.
I think this would be all I need as a different alternative.

Thanks so much again. Every one of your responses leads me to so much more understanding.

Stuart
#10
On Win XP and later, Button controls and ToolbarWindow32 control buttons automatically show border or change color on mouse hover ("hot" state). Unless visual styles are not applied. Visual styles probably are removed from an ownerdraw Button control. On XP, Buttons have problems with displaying icon and text. If you need button icons, better use ToolbarWindow32, not Button.
#11
Newest QM 2.3.0 versions have an undocumented function __OutWinMsg. It shows received Windows messages in qm output. May help in programming dialogs. Example:

Function Dialog35
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("Dialog35" &Dialog35)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;END DIALOG
;DIALOG EDITOR: "" 0x203000B "" "" ""

ret
;messages
__OutWinMsg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#12
Hi Gintaras,
I think I got it, for real this time!!!
I hacked TrackMouseEvent.qml
http://www.quickmacros.com/forum/showthr...p?tid=3126 down to minimum needed for button-swapping.
I had to write accompanying function to turn off the hovered button appearance (id 7) when it became sticky. I don't understand why sometimes it becomes sticky. I think it has to do with the relative size of the images relative to the dialog itself, which is triggering the swapping. Anyway, my bmps were made kind of sloppy so maybe that won't be necessary if I made them more carefuly. Also more likely it is something about the TrackMouseEvent function which I don't yet understand (though I did read about it in MSDN). Anyway, check out my code below. I am sure someone in the community can make it much better since I was basically just hacking at TrackMouseEvent.qml

Function SwapButtonImageOnHoverInDlg
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

def WM_NCMOUSEHOVER 0x2A0
def WM_MOUSEHOVER   0x2A1
def WM_NCMOUSELEAVE 0x2A2
def WM_MOUSELEAVE   0x2A3
type TRACKMOUSEEVENT cbSize dwFlags hwndTrack dwHoverTime

if(!ShowDialog("SwapButtonImageOnHoverInDlg" &SwapButtonImageOnHoverInDlg)) ret

;BEGIN DIALOG
;0 "" 0x90080A44 0x0 0 0 135 17 "TrackMouseEvent"
;1 Button 0x54030001 0x4 38 0 48 14 "OK"
;2 Button 0x54030000 0x4 86 0 48 14 "Cancel"
;6 Button 0x54032000 0x0 1 1 33 15 " "
;7 Button 0x54032000 0x0 1 1 33 15 " "
;END DIALOG
;DIALOG EDITOR: "" 0x2030003 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam)
,ont hDlg
,TRACKMOUSEEVENT-- tm
,tm.dwFlags=0x2 ;tm.hwndTrack=(hDlg); tm.dwHoverTime=1 ;tm.cbSize=sizeof(tm);;;
,,int bm=qm.LoadPictureFile("$my pictures$\Open.jpg"  0) ;;loads bmp, gif or jpg. With QM < 2.1.8.4, use int bm=LoadImage(0 _s.expandpath("$qm$\de_ctrl.bmp") IMAGE_BITMAP 0 0 LR_LOADFROMFILE)
,,SendMessage(id(6 hDlg) BM_SETIMAGE IMAGE_BITMAP bm)    
,,int bm2=qm.LoadPictureFile("$my pictures$\OpenHover.jpg"  0) ;;loads bmp, gif or jpg. With QM < 2.1.8.4, use int bm=LoadImage(0 _s.expandpath("$qm$\de_ctrl.bmp") IMAGE_BITMAP 0 0 LR_LOADFROMFILE)
,,SendMessage(id(7 hDlg) BM_SETIMAGE IMAGE_BITMAP bm2)        
,
,ret 1
,
,case WM_SETCURSOR
,if wParam=id(6 hDlg)
,,hid- id(7 hDlg)
,,Zorder(id(7 hDlg))
,,mac "TurnOffStickyHover"
,,
,case WM_MOUSEMOVE
,,TrackMouseEvent(&tm)
,,hid id(7 hDlg)

,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
,case 7
,,mes "hello"
ret 1

Function TurnOffStickyHover
Code:
Copy      Help
wait 0.1 M
err
,hid id(7 win("TrackMouseEvent" "#32770"));err

Anyway, this works. I can make pretty great simulations of the buttons I want in the style of the app using just Paint or even better with program like ButtonGadget2 and then hang the dialog as a hook on a toolbar on the app where I want it.

http://www.buttongadget.com/buttongadget2/default.htm
That program does create javascript onMouseover statements for the button it makes but I think this only works in html. Could those be incorporated into regular dialogs in QM?
I also found a program called 3D Active Button Magic at http://www.multimediasoft.com/
It describes this for incorporating into your projects. I have no idea what any of this means but I know that QM is extendable with additional ActiveX components, etc so hope this helps someone.
Thanks to all!!!,
Stuart


Quote:RUN-TIME:
The control's appearance and behavior can also be modified at run-time. For those using the product within the C++ environment, the download package includes a module named 3dabm8.h that will help you with the mnemonic constants required by the control. This module can be found inside the Include directory created by the setup package (the default is C:\Program files\3D Active Button Magic\include).
As explained below, the demo modules for Visual Basic 6, Visual Basic.NET and Visual C# (that were available until version 6 of the control) have been discontinued due to the new internal object-oriented design of the control. Go to the How to use Mnemonic Constants section for details.
Using the control inside Microsoft Visual C++.NET
The use of ActiveX controls within projects developed using Visual C++.NET and MFC creates particular issues users must be aware of: as for Visual C++ 6.0, ActiveX controls require wrapper classes in order to be used in this environment. Usually these wrapper classes are generated automatically by the environment but, due to a bug inside Visual C++.NET, the wrapper class will result incomplete when dealing with ActiveX controls that, in order to maintain backward compatibility, alternates identifiers of properties and methods. For this reason our control comes with its already generated C++ wrapper classes, installed by the setup package inside the "include" directory (by default the complete path should be C:\Program files\3D Active Button Magic\\include\wrappers\cpp.net). This issue implies to perform some manual action when creating a variable associated to the control. We recommend integrating these wrapper classes into your projects using the following procedure:
Copy the following wrapper files into your project directory:
BtnEnh.cpp and BtnEnh.h
Cellsmanager.cpp and Cellsmanager.h
Font.cpp and Font.h
TextDescriptor.cpp and TextDescriptor.h
SurfaceColor.cpp and SurfaceColor.h
Texture.cpp and Texture.h
Add the wrapper files to your project.
Create one variable associated with a 3D Active Button Magic button, declaring the variable itself of type CBtnEnh without using the wizard provided by the environment.
Intellisense will now be able to display all the wrapper functions for all the control's COM interfaces.
#13
This is my version. I don't like TrackMouseEvent and instead use timer.
Function SwapButtonImageOnHoverInDlg
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("SwapButtonImageOnHoverInDlg" &SwapButtonImageOnHoverInDlg)) ret

;BEGIN DIALOG
;0 "" 0x90080A44 0x0 0 0 135 17 "TrackMouseEvent"
;1 Button 0x54030001 0x4 38 0 48 14 "OK"
;2 Button 0x54030000 0x4 86 0 48 14 "Cancel"
;7 Button 0x54032000 0x0 1 1 33 15 " "
;END DIALOG
;DIALOG EDITOR: "" 0x2030003 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,ont hDlg
,
,lpstr sb=
;$my qm$\macro682.bmp
;$my qm$\macro610 (2).bmp
,ARRAY(__GdiHandle)-- ab
,if(!ab.len) foreach(_s sb) ab[]=LoadPictureFile(_s)
,
,int-- hbtn1; hbtn1=id(7 hDlg)
,SendMessage(hbtn1 BM_SETIMAGE IMAGE_BITMAP ab[0])
,
,case WM_SETCURSOR
,if wParam=hbtn1 and SendMessage(wParam BM_GETIMAGE IMAGE_BITMAP 0)!=ab[1]
,,SendMessage(wParam BM_SETIMAGE IMAGE_BITMAP ab[1])
,,SetTimer hDlg 1 50 0
,,
,case WM_TIMER
,sel wParam
,,case 1
,,if(child(mouse)!=hbtn1)
,,,KillTimer hDlg wParam
,,,SendMessage(hbtn1 BM_SETIMAGE IMAGE_BITMAP ab[0])

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 7
,,mes "hello"
ret 1
#14
In programming, one function is definitely better than two to accomplish the same thing!!!
Thanks so much for your help on this!!!!
Stuart


Forum Jump:


Users browsing this thread: 2 Guest(s)