|
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
|
|
|
|
|
HI , Ijust was wondering how
can I get the handle (hfile) of my application file from its code
(i.e to get the hfile of the exe and the code to do so is in the same exe too)
thanks in advance
|
|
|
|
|
What's about retrieving the module file name and path with GetModuleFileName() and then just open it with CreateFile()
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
GetCurrentProcess() does that.
|
|
|
|
|
the scrollbars don't work. actually, the page up/down parts do (click in the track, outside the 'thumb' part) and the arrows do, but i can't drag the thumb bar. it doesn't move. it happens on both the vertical and horizontal scrollbar...
why is CListCtrl such a P.I.T.A. ??
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Hey, why don't you write your own list control and post it here? While you're at it, write a list box too, as that is pretty annoying (no clean way to change between single select and multiple select at run-time.)
Even if you win the rat race, you're still a rat.
|
|
|
|
|
you first
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
ah... found it... this one was my own stupid fault.
for future reference, if you're doing drag/drop and you're handing WM_CAPTURECHANGED, be aware that calling ReleaseCapture will cause you to be unable to grab the scrollbar thumb. so make sure you really want to release the mouse before you do it (like, only release if you're dragging something).
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|