|
Interesting but the question had to do with centering to the screen and not some unknown window. Also they specifically said Win32 and not some function that depends on MFC.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I think, you has not read my reply carefully. In my first reply, I suggested to use CWnd::CenterWindow . After that, OP indicated, he is using win32 api. So, I simply shown him how this function is implemented using win32 Api. And while implementation, its taken care of considering both possiblities.
John R. Shaw wrote: Also they specifically said Win32 and not some function that depends on MFC.
In original post, he has not mentioned No MFC this.
|
|
|
|
|
1) I did read your reply carefully and the function you showed him is not using the Win32 API directly. What you showed him was a function that depended on MFC and C++. The Win32 API does not depend on MFC and I believe it is written in C and not C++, as are all of the Windows operating systems before it. Your code starts off with a C++ name and contained lines with function calls like “Afx…”; no matter how you look at it those are not Win32 API call, they are MFC calls.
2) True he did not mention ‘No MFC’ in the original post, but the one you gave an answer to said “But Master, it's WIN32.”.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: not using the Win32 API directly
Again, let me explain, what I tried to explain, I told him, see how CenterWindow is implemented, And I just pasted code , how it's defintion. So it was up to OP to extract solution from it(and there are win32 api's used there).
|
|
|
|
|
Yes I see your point.
You are applying the concept of working backwards; which I have used often. I was approaching it from the Win32 (C code) point of view. I did suggest that he create a small program using MFC and then work backwards to see how they did it, using the code browser. MFC hides a lot of things and unless you know what it is hiding then it is hard to determine what a piece of it is doing.
We where approaching the problem from opposite directions. I try to answer the questions (from memory) at the level from which they were asked. If you look further down in the posts (the one with no replies) you will see my center window solution. The only problem with it is that you need a handle to the window; which common dialog boxes do not give you unless you over ride (hook) the class (not a C++ class) and create them directly.
I do know where you are coming from and apologize if you thought otherwise.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: If you look further down in the posts (the one with no replies) you will see my center window solution.
I saw that, and suggested OP to refer[^] it.
John R. Shaw wrote: The only problem with it is that you need a handle to the window;
I think, that very obvious, without window handle, its very difficult to operate on window.
John R. Shaw wrote: which common dialog boxes do not give you unless you over ride (hook) the class (not a C++ class) and create them directly.
I suggested him to handle it in HookProc[^].
John R. Shaw wrote: I do know where you are coming from and apologize if you thought otherwise.
Never mind, it bound to happen, due to communication mismatch.
Anyway, nice to have this communication.
|
|
|
|
|
You funny! LOL
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Thanks !
My main application window screen is now in center but the browse file and brwose
directory dialog is still display the dialog in the upper left corner.For that I have did the same thing but it is unable to handle.
becuse of this is a structure so for that how can I use this one for dispaying the fileopen dialog
in the center?
OPENFILENAME ofn;
I have passed the owner window but I think its not helpful me..????
Window_Center(ofn.hwndOwner);
GetOpenFileName(&ofn);//When this will open the dialog it must in the center. but its not working.
how can this works ?
Amit
|
|
|
|
|
amitmistry_petlad wrote: ofn.hwndOwner
It is handle to owner of dialog, not to the dialog.
You may need to use OFNHookProcOldStyle . Handle WM_INITIDIALOG message there. And center the window with given code.
|
|
|
|
|
Like I said, I was not sure if it would help. That code depends on having the handle to the window that you want to center on the screen. There are ways to override common windows behavior called hooking that will allow you to do what you want, so I suggest that you look that up. You will need to dig a little deep and remember that each window has its own class name (not a C++ class name), look up ‘CreateWindow’ in the MSDN and you will have a start on what I am referring too.
I would like to be of more help, but it is the middle of the night here and I should be asleep.
P.S. Next time post your reply to the post you are replying to or I might not notice it.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
amitmistry_petlad wrote: ...it's WIN32.
So how about stating all of your requirements in your initial post!?
Be sure and specicy the OFN_ENABLEHOOK flag. In response to the WM_INITDIALOG message in the hook procedure, simply call CenterWindow() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
This is a very old function and I do not know if it will help.
void Window_Center(HWND hWnd) {
RECT rc;
int w,h;
GetWindowRect(hWnd,&rc);
w = 1+rc.right-rc.left;
h = 1+rc.bottom-rc.top;
rc.left =(GetSystemMetrics(SM_CXSCREEN)-w)>>1;
rc.top =(GetSystemMetrics(SM_CYSCREEN)-h)>>1;
MoveWindow(hWnd,rc.left,rc.top,w,h,TRUE);
}
If that does not help, start searching for the multitudes of FAQs on the NET because it is a common question.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
exploite environment:2003SP1 PlatformSDK + VC6
error information:
error LNK2001: unresolved external symbol _IID_IHTMLInputElement
error LNK1120: 1 unresolved externals
error code:
CComPtr<ihtmlinputelement> *pIInput;
hr=pDisp->QueryInterface(IID_IHTMLInputElement , (void**)&pIInput);
|
|
|
|
|
It doesnt have any problem on the VS2005
|
|
|
|
|
MyNothing wrote: hr=pDisp->QueryInterface(IID_IHTMLInputElement , (void**)&pIInput);
Use __uuidof(IHTMLInputElement) instead of IID_IHTMLInputElement .
Modify your code to,
CComPtr<IHTMLInputElement> pIInput;
hr=pDisp->QueryInterface(__uuidof(IHTMLInputElement), (void**)&pIInput);
|
|
|
|
|
MyNothing wrote: IID_IHTMLInputElement
try __uuidof(HTMLInputElement)
|
|
|
|
|
ThatsAlok wrote: try __uuidof(HTMLInputElement)
You meant to say __uuidof(IHTMLInputElement), isn't it ?
|
|
|
|
|
prasad_som wrote:
You meant to say __uuidof(IHTMLInputElement), isn't it ?
ohh sh*t.. you have posted correct reply more than 2 hr before me.. is cp clock playing with me..!
|
|
|
|
|
ThatsAlok wrote: is cp clock playing with me..!
Its happening for last 2-3 days, reported by many people already. Some thing to do with day light saving.
You missed I from IHTMLInputElement in your reply.
|
|
|
|
|
Not only that ..........
He also missed I from sh*t ........
|
|
|
|
|
Ranjoy Guha wrote: He also missed I from sh*t ........
just try write sh*t with i and post it on cp..
|
|
|
|
|
Ranjoy Guha wrote: He also missed I from sh*t ........
See before commenting on someone!
|
|
|
|
|
Sir
Thats just a joke............
I am extremely sorryf I have hurt you....
Regards
Ranjoy
|
|
|
|
|
Ranjoy Guha wrote: I am extremely sorryf I have hurt you....
its' ok dear.. i am jokin too
|
|
|
|
|