|
I quick look at MSDN did not produce the answer, but there is a function (I forget the name) that will give you a handle to a window based on the name of the window (name on title bar). Take a look around codeproject, codeguru, programmers haven, etc... There are articles that explane how to do what you want, if not directly then indirectly. For instance, there are programs that allow you to point at a window with the mouse and get all the information you want about it (up to and including capturing it to a bitmap file). I know, they use a function that gets the window handle based on given coordinates. Since you already have the process ID, you should be walk its' contents some how.
Well I hope this gave you some idea in which direction to look.
Good luck!
INTP
|
|
|
|
|
Thank you very much! And the function you mentioned is FindWindow().
|
|
|
|
|
Is it possible to get a function pointer which is 100% the original pointer?
I know that GetWindowLong() will return the function pointer, but I need a gaurunatee that the pointer I extract is the opriginal pointer not a subclassed function pointer.
I don't have the option of saving the original pointer when the window is first created, like inside WinMain() and after RegisterClassEx() ...so thats out of the question...
Is there anyway I can get the previous function pointer from the current pointer???
[EDIT]
DefWindowProc() I don't think is what I want.
Unless it calls the original WndProc that developers assigned to WNDCLASS when they created the window. I need the function pointer to the function which will handle not just generic window messages...
Does DefWindowProc() actually call the function specified by programmer or does it just handle message generically?
[/EDIT]
Hope I made my dilema clear...
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
If you know the what the name of the origanal function was then you already have a pointer to it. As for getting the previous pointer from the current pointer, I dought it. You might take a look at one of Jeffrey Richters' books, there the best books on Windows programing I have ever read (Hey man, when microsoft wants there employees trained the call Jeffrey).
INTP
|
|
|
|
|
No I wouldn't have known the name of the original procedure...becuz of what it was I was trying to do...however I have just read an article that cleared everything up...I can't accomplish what I wanted to using the techniques I was planning on using...
Sux when that happens...
Ah well
Cheers
p.s-I've read alot "about" Richter books lately...I really should go grab one...
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
|
Try the following :
either :
- use GetClassLongPtr(hWnd, GCLP_WNDPROC) which should not be changed when a window is subclassed as subclassing is window specific, and this is class specific.
or,
- get window classname
- create a new hidden instance of that window class
- get wndproc of new window
- this should be the same, original, wndproc for all instances of window class
- delete hidden window
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Please let me know how to access the ActiveX control(from 3rd party developed in VisualBasic) from Visual C++ ????
If possible let me know the sample code.
|
|
|
|
|
The language used to write an ActiveX control does not matter.
Look up ActiveX in MSDN. The sub catagory "what is an ActiveX control" points you totorials on ActiveX controls. Also, search codeproject and its' associated web sites for articles on the subject.
INTP
|
|
|
|
|
I am trying to build a number of straight C++ projects that were made with VC6 and I am getting a gazillion template errors. I tried specifically with VS.NET 2003 and it was a horror show of hundreds of compile-time template problems, when I switched to VS.NET (version 1) I was able to fix a mere few errors and it built fine.
Why the big discrepency? Is there a guide of FAQ on common issues for porting VC6 "compliant" template code to VS.NET 2003?
If not there should be because this is a royal pain in the you know what.
Any pointers are appreciated.
|
|
|
|
|
There was a huge leap in C++ standards conformance from VC6 to .NET. If you're having a lot of trouble, it means the original code was not standard conformant.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Ok, that much I understand. How does one go about fixing it? Also, its interesting that I got it built easily in VS.NET but it was so much of a problem with VS.NET 2003.
|
|
|
|
|
Anonymous wrote:
How does one go about fixing it?
By changing the code into proper C++
Anonymous wrote:
Also, its interesting that I got it built easily in VS.NET but it was so much of a problem with VS.NET 2003.
Yeah, VS.NET had a new STL and some improvements, but I'm pretty sure it was 2003 that had the quantum leap.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Eh, tough audience. I guess I am looking for a list of the top areas where VC6 forced you to use non standard template code. Maybe that is too much to ask for, but I'm guessing there are commonly known issues with templates with VC6 that would give me a big head start in terms of converting. I am not a template master and anything that can help would be appreciated.
|
|
|
|
|
Here's an example:
Here's an example:
template <class T> class VertexLock<br />
{<br />
public:<br />
<br />
VertexLock( T* obj, T::LockType lock ) :<br />
m_obj(obj)<br />
{<br />
obj->lockVertices( lock );<br />
}<br />
<br />
<br />
~VertexLock()<br />
{<br />
m_obj->unlockVertices();<br />
}<br />
<br />
private:<br />
T* m_obj;
<br />
VertexLock();<br />
VertexLock( const VertexLock& );<br />
VertexLock& operator=( const VertexLock& );<br />
};
warning C4346: 'T::LockType' : dependent name is not a type
prefix with 'typename' to indicate a type
|
|
|
|
|
<small><b>Anonymous wrote:</b></small>
<i>warning C4346: 'T::LockType' : dependent name is not a type
prefix with 'typename' to indicate a type</i>
This is just a warning, it will still compile, and it's telling you the solution as well. You should check the "Do not treat <'s as HTML tags' box below the post if you want to post template code.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Sorry, there was actually an error message associated with that code, it was the following referring to the first line of the template:
error C2226: syntax error : unexpected type 'T'
error C2334: unexpected token(s) preceding ':'; skipping apparent function body
|
|
|
|
|
Anonymous wrote:
Eh, tough audience
LOL - you get extra credit for having a sense of humour
Anonymous wrote:
I guess I am looking for a list of the top areas where VC6 forced you to use non standard template code.
I don't know of any where it FORCED you, only that it ALLOWED you at times. the only case I know of is the only one that got me when I upgraded, and that only once. I used an iterator as a pointer to the item instead of converting it to be one. But then, I've always been fastidious about C++ syntax.
Anonymous wrote:
I am not a template master and anything that can help would be appreciated.
I'd be happy to help, perhaps if you post some code that is breaking ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
No problem, I know I should probably RTFM but templates is a big subject. I think once i get rolling I'll probably start to pick up the things that are making this break.
Thanks
|
|
|
|
|
I had the same problems as you describe and ended up going back to VC6 because the effort to fix all the compiler errors was not worth it.
John
|
|
|
|
|
BOOL CDC::GetCharWidth( UINT nFirstChar, UINT nLastChar, LPINT lpBuffer ) const;
I found this function a little hard to understand, as stated by MSDN, this function takes 2 UINT's as the 1st and 2nd chars in a consecutive group of characters, the 3rd parameter is an array of int's which is retrieving char widths. This leads to my confusion, in practical, we often want to determine the width of a particular char or string, not something like 'A' to 'Z' or 'a' to 'z'. For example, if I want to know width of string "Hello Code project!" then what should I do? This string has length of 19, do I need to call GetCharWidth 19 times each time pass in something like "'H' to 'H'", "'e' to 'e'", "'l' to 'l'" and so forth?
I mean, why wasn't this function like this: int CDC::GetChatWidth(TCHAR ch) const or int CDC::GetCharWidth(LPCTSTR lpString) const , simply take a char or string and return its width? Sorry if this sounds like a stupid question, but I'm really confused.
|
|
|
|
|
=[ Abin ]= wrote:
int CDC::GetChatWidth(TCHAR ch) const
You can get this by passing in just the char you want, surely ? A helper function to do what you want would be easy to write, just write a CDCFacade class.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
There are some very good applications for GetCharWidth(), determining the display width of string is not one of them. Let's just say it is far more complicated than you want to know at this point in time.
If you need to know the display width and height of a string, use one of the text extent functions: GetTextExtent(), GetTabbedTextExtent(), etc...
Internaly the text extent functions may be calling GetCharWidth() to help in determining the size of the final bitmap image.
I have used GetCharWidth() in the past in order to create DOS style binary font bitmaps for Windows fonts (TT, etc...). That is only one of 2 situation that I found where this function is useful. Of cource if you could figure out what mathimatical algorythms are used to determine charater placement strings in Windows, then by all means write an acticle and let the rest of us know.
If you tried to use GetCharWidth() to determine the displayed legnth of a string, I'm here to tell you that it is not possible unless the font used is not variable spaced. If you dig into the subject you will find that you have to deal with thing like overhang, underhang, spacing between characters, and a whole host of other variables (depending on font type).
The short of it is that GetCharWidth() is only useful in a few specelized situation.
INTP
|
|
|
|
|
Thank you for the detailed explanation.
|
|
|
|
|
How can I prevent my app from being closed (Other than from the task manager)?
What messages can I trap to prevent it from closing?
|
|
|
|