-
(With help) I have a menu that dynamically reads and replicates another app's menu, then subclasses itself and passes the menu messages to the other app. When my app loses and regains focus, the menu disappears so it has to be recreated and the user sees this. I've also created one that doesn't use SetMenu but once it subclasses, the menu disappears upon losing focus. So what can I do to subclass but keep the user from seeing a flickering menu?
Thanks in advance,
Wade
-
When you subclass the menu, send all the message codes to debug, then try to pinpoint the message that makes the menu dissapear and intercept this, or why do you want the menu to stay up when you select an Item anyway, shouldn't it dissapear?
hope this helps
-
I don't mean that the submenus disappear when selecting an item. Rather, the entire menu bar disappears and needs to be recreated. I'll try to nail down the message that's making it disappear, but whenever I don't pass the message it crashes. Can you [not] pass the message?
Thanks,
Wade
-
It depend's on the message,obviously if it's the appactivate message or something system wide like that it's not a good Idea to ignore it, but a lot of messages if you change the result and change what messages windows sends later, make sure you save your work a lot though, or you could use bitblt to make a false menubaar underneath the old one so nobody notices the flicker.
-
Can you place a false menu bar in the same position as a normal menu? If you draw a normal control at the very top of your form, the menu is above it. I haven't used bitblt so forgive me if this part sounds amateur-ish (is that a word?).
Thanks,
Wade
-
I don't know, I litterally thought of it as I was typing the last message, try different things, you can easily put a -ve number for the y coord in bitblt. I've included my decleration of bitblt
Code:
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop as RasterOpConstants) As Long
it's the last parameter that throws people, if you declare it my way you'll get a nice piclist of possible values for the last parameter, use vbSRCCopy. to get the menu bitmap you'll have to bitblt the menu into a memory dc, use WindowFromPoint and GetDC to get the srcDC for the first bitmap and create a memory DC for the target, NB you'll nee d to create a new bitmap for the memory DC and attathch it using select object.
Someone else needs to use the line so I can't explain but if you havn't done that before Post something up and Ill explain in detain later.
-
If you could explain that more in detail, I'd appreciate it. I'm not new to vb, but I haven't used BitBlt.
Thanks,
Wade
-
This is an example of how to use Bitblt:
BitBlt Me.hDC, 0, 10, Me.ScaleWidth, Me.ScaleHeight, srcDC, 0, 0, vbSrcCopy
It will move the form image 10 pixels up.
I tried to use Bitblt with a menu but the menu is not a part of the form DC... and menus don't have any DC?
-
Sorry, I still haven't written a bitblt Example, I'm surprised you haven't seen bitblt before, How much do you know about DC's etc
this is what all the bit's of BitBlt do, remember all measurements are in pixels.
hDestDC as long the DC handle of the window you want to copy from
x, the x coord of the top left corner of the place you want to paste the image to
y, the y coord of the top left corner of the place you want to paste the image to
nWidth the width of the image you are pasting
nHeight the height of the image you are pasting
hSrcDC the handle of the DC you are pasting from
xSrc, the xcoord of the top left corner iof the part of the image you want to capture
ySrc, the ycoord of the top left corner iof the part of the image you want to capture
dwROP the Raster Operation you want to perform,
Rater Operations are bitwise operations on the long colour values in the source and destination DCs, srcCopy wil just paste the image onto the destination as you would expect.
-
Could you send me your code so I can have a look at it, i'm at [email protected]
-
Sam,
Thanks for the help. I think I have an easier way. I've created a menu that replicates the external app's menu but isn't subclassed to another app. I can process the messages myself by grabbing the external menu ID based on similar menu position and call it. Consequently, the menu doesn't disappear, so no flicker.
Thanks again,
Wade