I'm trying to make popup object.
When Command1 get clicked, Text1 should show up exactly under Command1.
But it didn't.
I take a look on every sample on VBForum. It's should work.
Strangely When i try it with two FORM (Another Form show up under Command1, when command1 get clicked), it succeed.
Change your form's ScaleMode property to Pixels. That gets rid of the Twips issue.
And you need to subtract the form's on-screen position from the values returned by GetWindowRect. Remember the coordinates for form controls are relative to the 0,0 position of the Form. The coordinates for a hWnd are all returned relative to 0,0 on the screen.
No, sample i attched only an "EXAMPLE". My application are big . and it include many control position and form resize which is already on twip. I can't change baack to pixel.
Btw, as i mention before. i try it with two FORM and it work flawlesly. I just don't want using two FORM for this part of code, since it will make so many form.
Well like I said I can't look at your sample and the Twips thing was only a suggestion. The rest of my post still applies, just add in the appropriate pixels -> twips conversions.
you need to subtract the form's on-screen position from the values returned by GetWindowRect. Remember the coordinates for form controls are relative to the 0,0 position of the Form. The coordinates for a hWnd are all returned relative to 0,0 on the screen.
Actually, why can't you just use the command buttons's Top and Height property to work out the position? Would be a darn sight quicker than calling API functions.
You genius, it work.
But will it work, when using with mdi child form?
Where tje main form toolbar can have one toolbar, two toolbar, so on. Depend on user setting to the appplication?
It should show in the correct position as long as it is placed within the same form as the combo box. If it's not in the same form, or floating in the MDI client area, you have another difficulty. Can you confirm where it's located?