|
Christian Graus wrote:
You need to delay load the dll
... or call GetProcAddress for the "extended" functions.
|
|
|
|
|
In the MSVC documentation, SetActivateWindow() activates a window - however this must be associated with the calling thread's message queue. Is there a way that I can pass control from my program to another app's main window knowing it's handle ?? (I have got the handle using EnumWindows() and checking the window title). Appreciate any help
Doug
|
|
|
|
|
ummmm this might be dumb but cant you send a mouse click message to its message queue ... that would make the whole thing happen as if the user clicked it
just a thought
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
|
doh!
i knew there would be an easy way
i was too lazy to squizz thru the msdn stuff
sorry
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
lauren wrote:
i knew there would be an easy way
Sadly under 2K and XP, it won't actually make it foreground
It'll just flash the taskbar icon thrice. Unless you change this setting using Powertoys. Something about preventing apps from stealing focus.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Before calling SetActiveWindow, use the AttachThreadInput function to attach the input states of the calling thread and the thread with the desired window:
DWORD tidThis,tidOther;
tidThis=GetCurrentThreadId();
tidOther=GetWindowThreadProcessId(hwnd,NULL);
if(tidThis!=tidOther)
AttachThreadInput(tidThis,tidOther,TRUE);
SetActiveWindow(hwnd);
if(tidThis!=tidOther)
AttachThreadInput(tidThis,tidOther,FALSE);
Peter O.
|
|
|
|
|
Peter, that code works a treat !! Many thanks for your help - I've learnt something ! Thanks also to all the others who contributed to this thread.
Doug
|
|
|
|
|
Hi,
I'm a complete newcomer to Visual C++, and have just downloaded the MFCGridCtrl component from this site. My question is simple - I've included the files into my project in VC++6, but how do I place an instance of the MFCGridCtrl onto my dialog? Please explain how to do this step-by-step, assuming I have just downloaded the source code files...
Thanks a lot for any help on such a dumb question,
Jonathan.
|
|
|
|
|
Did you get the demo program? If not, download it too, then look to see how it was implemented. You might also compile the demo for debug then step through some of the demo program to see how it works.
|
|
|
|
|
Hi,
Thanks for your reply, but I'm afraid it hasn't helped me much...my problem is not actually USING the control once it is in my application, but actually getting it into my app in the first place. Its not a problem specific to this control, just a general procedure I guess.
I've programmed in Delphi, where importing 3rd party components and placing them on a form is easy...it seems a bit less obvious in visual c++?? I thought I would just be able to drag and drop the control onto a dialog the same as an edit box, for example, but obviously not...
Jonathan.
|
|
|
|
|
hi!
sorry i come here for help, not help u.
i can't find site u said to download MFCGridCtrl, could u post its address? it looks interesting.
thx
includeh10
|
|
|
|
|
|
First you have to register the control on your computer. cd to the folder that contains the control, then enter "regsvr32 -r mycontrol.ocx" <enter> If it an ActiveX control it will most likely have an "ocx" extension. Otherwise it may have a "dll" extension.
Once registered, you can add it to your VC6 project by doing this:
1. Select Project | Add To Project | Conponents and Control
2. In the dialog box that appears, you will probably see two folders: "Registered Active X Controls" and "Visual C++ Components". Double click on "Registeredd Active X Aontrols".
3. This will bring up a list of all the ActiveX control that are registered on your computer. Highlight the control you want, then press the "Insert" button. I use MSFlexGrid control a lot, but the cells cannot be edited.
4. When "Insert the Component?" prompt appears, click the Ok button.
5. When the "Confirm Class" dialog box appears, use the default settings and just press the Ok button.
6. At this point, you can add other controls if you want to. When you are done, press the "close" button.
Now you can drag the control onto your form.
|
|
|
|
|
Nice one - it was the registering the control using "regsvr32 -r mycontrol.ocx" that I was missing.
Thanks a lot,
Jonathan.
|
|
|
|
|
Place a custom control in the dialog and give its resource id in the DoDataExchange function of the dialog class.
You can find that code in the DoDataExchange function from the code you have downloaded.The grid will be visible if sone rows ans columns are set,otherwise it will tell "failed to create document".All the best.
munafmohamed
|
|
|
|
|
Place a custom control in the dialog and give its resource id in the DoDataExchange function of the dialog class.
You can find that code in the DoDataExchange function from the code you have downloaded.The grid will be visible if sone rows ans columns are set,otherwise it will tell "failed to create document".All the best.
munafmohamed
|
|
|
|
|
well I don't know much about internet programming
but I need my application to do some action when the user connects to the internet
in other words
* while the pragram is running
when connected fire some event(or simply call afunction)
when connection terminated do othe action
thanks for your time
|
|
|
|
|
This function determines whether the user is connected to at least one RAS connection. Link with rasapi32.lib.
You can use this function to start your program.
#include <windows.h>
#include <ras.h>
BOOL IsUserConnected(){
RASCONN *rasc=malloc(1000);
DWORD bs,nc,i,j,dwRet;
RASCONNSTATUS rcs;
MSG msg;
TCHAR s[257];
rcs.dwSize=160;
rasc->dwSize=412;
dwRet=RasEnumConnections(rasc,&bs,&nc);
if(!bs)return 0;
rasc=realloc(rasc,bs);
if(RasEnumConnections(rasc,&bs,&nc))
return 0;
for(i=0;i<bs/412;i++){
HRASCONN hrc=rasc[i].hrasconn;
dwRet = RasGetConnectStatus(hrc, &rcs);
if (dwRet != ERROR_INVALID_HANDLE)
continue;
if (dwRet != ERROR_NOT_ENOUGH_MEMORY){
SetLastError(dwRet);
return 0;
}
if(rcs.rasconnstate==RASCS_Connected)
return 1;
}
return 0;
}
Peter O.
|
|
|
|
|
Also see InternetGetConnectedState() . You can call it in a timer handler and fire events when the connection state changes.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
hi ravi
this function puzzles me cos it seems to fail when u are connecting thru a shared connection across a local network ... ie, it always thinks ur connected even if the connecting (server) machine isnt actually connected
have i got something very wrong?
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
Ugh, thank you Microsoft.
I haven't tried it in that mode. It seems to work when you're connected thru a LAN or dialed in via a modem. Perhaps Peter's RAS approach is more robust?
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
i dont really blame them for bad api functionality cos the only reliable way i found was to try a ping on the server before assuming a connection was actually there ... i found a timeout of 10 seconds gives a fair compromise between a user waiting too long and the net being a little slow
if there is a better way i would like to hear it
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
You're right. But testing for a ping needs to be done in a separate thread (i.e. in a non-blocking manner) for it to be useful. I can't think of a foolproof and efficient way to do this.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
thats why i use a timeout of 10 seconds ... a klunk of a compromise but at least sanity shows its face occasionally
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|