|
Yes, but only by using a global hook. There is information on MSDN about how to do this.
Basically you set a global hook (usually a WH_CBT hook) from inside a DLL and when the hook function is called by Windows for a particular process, your DLL is loaded into the address space of that process. You can then subclass whichever windows in that process you want. Usually, you set a hook that activates whenever the HCBT_CREATEWND code is passed (a window is created), but if the window is already created, you may never get the opportunity to subclass it.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
You're welcome
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Am not sure, but won't using WH_CALLWNDPROC or WH_CALLWNDPROCRET hooks to obtain the handle of the window or its controls after creation then using SetWindowLong() to set the GWL_WNDPROC property could do the job of subclassing the window after its creation?
|
|
|
|
|
WH_CALLWNDPROC hooks are called from the context of the process that calls SendMessage() , not the one that receives the message. As long as a message is sent by the same process as the one you're wanting to subclass the window in, it should be OK.
These will work, but these hook functions are called for every message sent to every window. They substantially slow down the system and are not recommended unless absolutely necessary.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hello,
Is there any means to update editboxes individually?
For example I have 3 editboxes (one of which is kept blank & readonly when certain condition prevails). When I update data, the focus moves to the readonly (blank) box. Can anybody help me to overcome this?
Pani
Humble learner
|
|
|
|
|
Use a static text instead of an edit box, unless the user needs to be able to select and copy text out of it. If it has to be an edit box, then call SetFocus() on another window after you update the text box to remove the focus from it.
It the user doesn't need to be able to select and copy text from the edit box, then a static text box is the better option.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
How to close Excel from my c-program, if i've opened it with ShellExecute.
HINSTANCE hInstance= ShellExecute(
GetSafeHwnd(),"open","c:/test.xls",NULL,NULL,SW_SHOWNORMAL);
Thx
|
|
|
|
|
You can't close it that way. Use ShellExecute[b]Ex[/b] you get then a handle to your open Excel instance. The other way is to
find excel with "FindWindow" and then send a "WM_CLOSE" or "WM_SYSCOMMAND - SC_CLOSE" message.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
A better way would to use CreateProcess instead of ShellExecute, so that you can kill the associated thread or process.
~RaGE();
|
|
|
|
|
@Rage
ok if i create my own process for this, how can I the Excelfile I want to?
If I start it the same way with ShellExecute It would be the same effect. Excel would start in an own process but not in the one i've created for it
|
|
|
|
|
Set the lpCommandLine member of the CreateProcess call to the filename that you want to open.
onwards and upwards...
|
|
|
|
|
Anonymous wrote:
If I start it the same way with ShellExecute It would be the same effect. Excel would start in an own process but not in the one i've created for it
What do you mean ? With CreateProcess , *you* start the excel process. The last parameter of create process, which is a PROCESS_INFORMATION struct, contains the process handle and the starting thrad handle. Use ExitProcess() on the process handle, and you're done.
~RaGE();
|
|
|
|
|
hi,
i am newbie to STL.
i want to know if i have a list for storing struct. after i insert a struct in it, it will store the reference or make of in the list?
my worry is memory leakage if i don't remove the struct properly after remove it from the list.
list<control> ctrllist;
void addtolist()
{
control a;
a.id=1; a.value=10;
ctrllist.push_back(a);
}
void removelist()
{
// how to remove from list properly?
//ctrllist.remove(???)???
}
any help?
thanks,
jim
|
|
|
|
|
the code should like this!
list<<control>> ctrllist;
void addtolist()
{
control a;
a.id=1; a.value=10;
ctrllist.push_back(a);
}
void removelist()
{
// how to remove from list properly?
// ctrllist.remove(???)???
}
|
|
|
|
|
You can use pop_back to remove the last-inserted element of a list. Also take into account that all elements remaining inside a list will get destroyed when the list itself is destroyed, so you don't have to worry about leaks in this respect.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
my case is that the list will be alive when the program is running. and, the record into list will add and remove during program running. so, i need the record delete immediately after i remove from the list.
why i concern this because i used CList in mfc b4, which need to delete the element(struct)'s pointer manually after you remove it from the list. so, i want to make sure whether i need to do such procedure with STL's list or not...
pls comments!
jim
|
|
|
|
|
You must carefully distinguish between storing objects or pointers to objects. In the first case, pop_back is all that it takes to prevent leaks. In the second case, it is your responsibility to delete manually the pointer, as in this piece of code:
list<control *> ctrllist;
void addtolist()
{
control* a=new control;
a->id=1; a->value=10;
ctrllist.push_back(a);
}
void removelist()
{
if(ctrllist.empty())return;
control* a=ctrllist.back();
ctrllist.pop_back();
delete a;
}
Your first snippet of code seems to imply that what you're storing are actual objects instead of pointers, so you shouldn't need to worry about these issues.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi I have some code written for a serial port class. Now I want to access the same serial port object from a number of different dialogues etc within my program. So I guess the best way to do this is by making the object global at the start of the application? Or is there another way? Also where do I put the decleration for a global variable in an MDI app?
Any suggestions much appreciated
Andy
|
|
|
|
|
other way would be to modify the constructors. Add a pointer to of Object.
|
|
|
|
|
could you explain in more detail?
Andy
|
|
|
|
|
create an own class that handles your actions with the serial port.
Start the Dialog, SDI or MDI. Create a Member of Your SerialPortClass in the Maindialog.
If you start an other Window add an pointer to your dialog class into the window constructor. Now you have acces to the members of the dialog
|
|
|
|
|
Put it in the Application class, then refer to it via theApp->member _variable.
Elaine
The tigress is here
|
|
|
|
|
nice one cheers
I get a bit stuck sometimes with the doc/view structure, coming from C/embedded stuff where I just have main!
Andy
|
|
|
|
|
Hi Friends,
I haven't tried VC++.Net till now..but out of curiosity i would like to know, what would be the significant difference in vc++.net over vc++6.0
I am basically a system programmer mainly use VC++ for creating DLL's and test applications to test the hardware...Can anybody throw light how vc++.net has the compatibility ratio with the vc++6.0 is concerned in various domains such as:
System software( accessing file, device, doing file operations,multithreading, synchronisation)
Data base access
Com applications
and any others..
Thanks,
Shiva P
|
|
|
|