Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common Dialog Position

Status
Not open for further replies.

154868

Programmer
Dec 5, 2003
23
0
0
Hello

I use the CommonDialog from the FoxPro Foundation Classes
(faq184-3106 'How can I select multiple files from windows')

If I open the Dialog, the position of the Form is allways top-left

Now my question:

How can I get the Form in a other position (.. center) ?

Any idea?

Andreas





Andreas Wichmann
DataBit GmbH
Switzerland
 
Andreas

This most likely would be achieved with a few API calls. You would need to retrieve the nHnd (handle) of the dialog with
Code:
[COLOR=green]* The GetWindow function retrieves the handle of a window that has the specified r...[/color]
DECLARE INTEGER GetWindow IN user32;
	INTEGER hwnd,;
	INTEGER wFlag

And send the desired postion with :


Code:
[COLOR=green]* The SetWindowPos function changes the size, position, and Z order of a child, po...[/color]
DECLARE INTEGER SetWindowPos IN user32;
	INTEGER hwnd,;
	INTEGER hWndInsertAfter,;
	INTEGER x,;
	INTEGER y,;
	INTEGER cx,;
	INTEGER cy,;
	INTEGER wFlags





Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Andreas (& Mike)

You can set MessageBox position, caption, etc.. with VFP only (using timer, ugly solution anyway), however you can't do the same thing for CommonDialog, because it is not the same Instance/Thread as VFP

There is a DLL wrapper (in UT) with position for CommonDialog but no multiselect option (the capability has been limited)

Search for ID: #14876

Good luck

-- AirCon --
 

Aircon

You can set MessageBox position, caption, etc.. with VFP only (using timer, ugly solution anyway), however you can't do the same thing for CommonDialog, because it is not the same Instance/Thread as VFP

I wonder what would make you say that? If you can retrieve the handle, you can reposition and resize anything either inside of VFP or outside. Care to expand?




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

I have tried this technique (timer) long ago. What happened is when VFP call the CommonDialog the VFP app will stop and wait for the Dialog not even the timer will run!

You can try this yourself:

Add nCounter property to the form. Add the timer object with interval 500 (half msec) then put this code

WAIT transform(ThisForm.nCounter) window nowait noclear
ThisForm.nCounter = ThisForm.nCounter + 1

So you can see the counter runs in the wait window.
Then call CommonDialog. You will see the wait window stop running! So if it is stop running how can we get the handle to the Dialog Window? This thing doesn't happened if you call a MessageBox. That's the different

-- AirCon --
 
Aircon

Sorry, I don't follow you. I was not refering to a timer, but rather prior to use the showDialog method, retrieve the handle, resize and reposition the dialog and then show it. Although I have not tried this.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Ok,

I think you haven't get it why the key to this tehcnique is TIMER. Why we have to use it? Because that window is not exist yet! It is created inside the function/API that we are calling. That's why we have to use the TIMER in order to get the handle to that window. This timer act like watcher. So when the window already created then the timer can get the handle. And this is the reason why I called an ugly solution.

If you call it prior to the call, which window are you refer to?

-- AirCon --
 
If you call it prior to the call

Oopss! :-D

What I mean is:
If you trying to get the handle prior to the call



-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top