|
How can i check whether user can pree ctrl key
Dinesh Asanka
|
|
|
|
|
Do you mean can they press it, or have they pressed it ? If the latter, GetASyncKeyState(VK_CONTROL)
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Do you mean can they press it, or have they pressed it ? If the latter, GetASyncKeyState(VK_CONTROL)
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I'm trying to use the grid control in a CFormView-based class, by inserting a custom control in the dialog. My application fails with "Failed to create empty document" message at startup, the trace information from a debug run is as follows:
WndProc: hwnd=0x4C03D6, msg = WM_GETMINMAXINFO (0x0000, 0x0012F9FC)
WndProc: hwnd=0x4C03D6, msg = WM_NCCREATE (0x0000, 0x0012F9D0)
WndProc: hwnd=0x4C03D6, msg = WM_NCCALCSIZE (0x0000, 0x0012FA1C)
WndProc: hwnd=0x4C03D6, msg = WM_CREATE (0x0000, 0x0012F9BC)
WndProc: hwnd=0x2D02FE, msg = WM_NCCREATE (0x0000, 0x0012F394)
WndProc: hwnd=0x2D02FE, msg = WM_NCCALCSIZE (0x0000, 0x0012F3C4)
WndProc: hwnd=0x2D02FE, msg = WM_CREATE (0x0000, 0x0012F394)
WndProc: hwnd=0x2D02FE, msg = WM_SIZE (0x0000, 0x014501E0)
WndProc: hwnd=0x4C03D6, msg = 0x0368 (0x0000, 0x0012F0E4)
WndProc: hwnd=0x2D02FE, msg = WM_MOVE (0x0000, 0x00000000)
WndProc: hwnd=0x4C03D6, msg = WM_PARENTNOTIFY (0x0001, 0x002D02FE)
WndProc: hwnd=0x2D02FE, msg = WM_SETFONT (0x500A043F, 0x00000000)
WndProc: hwnd=0x4C03D6, msg = WM_PARENTNOTIFY (0x0002, 0x002D02FE)
WndProc: hwnd=0x2D02FE, msg = WM_DESTROY (0x0000, 0x00000000)
WndProc: hwnd=0x2D02FE, msg = WM_NCDESTROY (0x0000, 0x00000000)
Warning: could not create view for frame.
Failed to create client pane/view for frame.
WndProc: hwnd=0x4C03D6, msg = WM_DESTROY (0x0000, 0x00000000)
WndProc: hwnd=0x4C03D6, msg = WM_NCDESTROY (0x0000, 0x00000000)
Warning: Window creation failed: GetLastError returns 0x00000000
Warning: failed to create CFrameWnd.
Warning: CDocTemplate couldn't create a frame.
The thread 0x4C4 has exited with code 0 (0x0).
The program 'D:\TEMP\gctest\Debug\gctest.exe' has exited with code 0 (0x0).
The first warning is caused by ::CreateDialogIndirect() failing when the CMainFrame is being created. Then everything else fails because there is no main window.
Any idea why the window creation fails? Is some additional initialization needed?
|
|
|
|
|
hi..if u wanna use gridcontrol... use active X.....Add dbgrid control and ado to your project......assign ado topo a recordsource......\
Set SQL in ado... Call the the id of ado from the dbgrid control......Add table and recordset u wanna call in dbgrid.....
These thing can be done in resource workshop that is in something.rc file....No need to code anything in the CMainFrm......
Ur problem occurs becoz another program might have running the recorsource at the sametime....
"LIFE IS AN ADVENTURE THAT SHOULD BE LIVED.... LOVE IS A PROBLEM THAT SHOULD SOLVED...LOVE YOUR LIFE!!"
CVASIVA
|
|
|
|
|
I guess I should have specified that I am trying to use Chris Maunder's MFC Grid Control 2.22, not an ActiveX component. I need a control with checkboxes and date pickers as cells.
Anyway, I solved the first problem myself, I had to include a member variable for the control in the view class (not mentioned in the documentation). But the control still doesn't work, in fact it doesn't appear at all on the dialog. Debugging shows that the control's Create() function isn't called.
Isn't the MFC framework supposed to Create() all the controls defined in the dialog template? If I must Create() the control myself, how do I access the control position and size information defined in the dialog editor?
|
|
|
|
|
> Isn't the MFC framework supposed to Create() all the controls
> defined in the dialog template?
Only if you add the corresponding call to DDX_Control in DoDataExchange.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks, this was just the information I needed
|
|
|
|
|
Try EasyGrid ActiveX as a substitute.
It must will be very helpful.
Download is available @
http://www.share2.com/easygrid/
|
|
|
|
|
Hi y'all!
I've got myself into a nasty situation again. I had to create a client and server application which would be put on different PC's and communicate using simple modems (analogue and ISDN).
Not having a good component for serial communication and having to build a protocol of our own on top of it, I used the MSComm ActiveX object in Visual C++ 6 (with Win2K SDK) for talking with the modems on the COM ports.
But when we started stress testing it, it turned out that the client suffered from a rather huge memory leak, and it wasn't in my code! (I'm sure of this, because a debug build doesn't dump any memory and the only thing that keeps on rising is the number of used CRT-blocks). The weird thing is that the server application uses the MSComm object almost in the same way and doesn't have this leak at all.
When continually connecting and talking to each other the client application rises about 20 Kb each minute, so within an hour or 8 the Client PC will be swapping like crazy.
The ONLY difference between the two programs is that the server application is the dialing party and the client application is the waiting party.
Anyone ever had the same problem??? I think there must be some difference in the order of function calls. Could this really be of any difference???
Structured programming vs. chaotic mind boggling
|
|
|
|
|
If you are using a VARIANT to read in data, are you clearing the variant when you are done with it?
cve
|
|
|
|
|
I use COleVariants which should do the trick:
// --- Code for reading ---
COleVariant vInput = m_pMSCOMM->GetInput();
CString sBuffer = vInput.bstrVal;
// --- Code for writing ---
COleVariant vSend = sMessage;
m_pMSCOMM->SetOutput( vSend );
Anyway, the same code is used for client and server and the server doesn't show ANY problems. If I use the VARIANTs in the wrong way, please tell me how to do it right.
Structured programming vs. chaotic mind boggling
|
|
|
|
|
Hello all!!
I've figured out where my memory leak was! It was the way I took the variant out of the GetInput function. Since I've never really been a VB fan I never liked variants anyway, but now I'm truly scared of them
The code that I used was wrong:
COleVariant var = MSComm1.GetInput();
This code leaves another copy of the variant hanging around inside the memory space of the MSComm object. If your client receives the content of several files, this means a lot of leaking memory.
The solution is as follows:
COleVariant var.Attach (MSComm1.GetInput());
This code explicitly tells the ActiveX component that we want to read the variant type and delete it from the COM-memory space...
Have fun!
Structured programming vs. chaotic mind boggling
|
|
|
|
|
I am having an object inherited from abstract base class (having some pure virtual functions).
My problem is this:
I create some objects of that type by calling new, and when I later call delete on them destructor is not being called! Destructor is simple (public, not virtual).
Is there any open bug in Visual C++ compiler regarding this ?
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
Which destructor? If you are talking about the base-class destructor, this is a classic one. The destructor must be virtual
|
|
|
|
|
Both base class destructor and inherited class destructor are plain public.
So, do you say that I must convert one of them to virtual?
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
Absolutely - your base class destructor must be virtual. This is how, for example, the designers of the string class stopped people deriving from it, they didn't make the destructor virtual.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I tried your tip and it works now
I have declared base class destructor as virtual.
Thanks again.
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
We have a server app that uses overlapped socket I/O that runs fine on a single-CPU machine under NT 4 and W2K and also on a dual under NT. We have just received a quad running W2K Advanced Server and our app blows up big time.
We have nailed the problem down to WSAAccept() returning 0 when nobody is trying to connect instead of -1 (i.e. INVALID_SOCKET). We tried hacking around this by checking for 0 as well as -1 but we ran into problems later on: we also receive data using overlapped I/O and when our event gets signalled we call WSAGetOverlappedResult() to find out how many bytes have arrived; this is failing with WSASYSCALLFAILURE ("A system call that should never fail has failed"!!!) and doesn't initialize the byte count variable.
We have stripped everything out into a test app, running on a single thread, as dumb and as simple as we can make it and it is still failing. We are not sure if this problem is SMP-related but that is certainly our first suspicion.
Has anyone ever seen anything like this?!?! It just occurred to me that we were using WSA- functions on a socket created by socket(), but apparently that is OK (from the MSDN: "Overlapped I/O follows the model established in Win32 and can be performed only on sockets created through the WSASocket function with the WSA_FLAG_OVERLAPPED flag set or sockets created through the socket() function").
This is our stripped-down sample app:
cout << "Creating a socket..." << endl ;
SOCKET hListenSocket = socket( AF_INET , SOCK_STREAM , 0 ) ;
if ( hListenSocket == INVALID_SOCKET )
{
cout << "ERROR: Can't create the socket." << endl ;
exit( 1 ) ;
}
cout << "- hListenSocket=" << hListenSocket << endl ;
struct hostent* pHostEnt = gethostbyname( pHostAddress ) ;
if ( pHostEnt == NULL )
{
cout << "ERROR: Can't resolve the host name: " << pHostAddress << endl ;
exit( 1 ) ;
}
in_addr hostAddress = *((struct in_addr *)pHostEnt->h_addr_list[0]) ;
cout << "Binding the socket." << endl ;
sockaddr_in addr ;
addr.sin_family = AF_INET ;
addr.sin_addr.s_addr = hostAddress.s_addr ;
addr.sin_port = htons( portNo ) ;
int rc = bind( hListenSocket , (sockaddr*)&addr , sizeof(addr) ) ;
if ( rc != 0 )
{
cout << "ERROR: Can't bind the socket ; rc=" << rc << endl ;
exit( 1 ) ;
}
cout << "Listening on the socket..." << endl ;
rc = listen( hListenSocket , SOMAXCONN ) ;
if ( rc != 0 )
{
cout << "ERROR: Can't listen on the socket ; rc=" << WSAGetLastError() << endl ;
exit( 1 ) ;
}
WSAEVENT hConnectEvent = WSACreateEvent() ;
rc = WSAEventSelect( hListenSocket , hConnectEvent , FD_ACCEPT ) ;
if ( rc != 0 )
{
cout << "ERROR: Can't set the connect event ; rc=" << WSAGetLastError() << endl ;
exit( 1 ) ;
}
cout << "Waiting for a connection..." << endl ;
SOCKET hSocket = WSAAccept( hListenSocket , NULL , NULL , NULL , NULL ) ;
if ( hSocket == INVALID_SOCKET )
{
cout << "- Connection pending..." << endl ;
WSAEVENT hEvents[1] ;
hEvents[0] = hConnectEvent ;
DWORD rc = WSAWaitForMultipleEvents( 1 , hEvents , FALSE , INFINITE , FALSE ) ;
if ( rc == WSA_WAIT_EVENT_0 )
{
cout << "Connection received." << endl ;
hSocket = WSAAccept( hListenSocket , NULL , NULL , NULL , NULL ) ;
cout << "- hSocket=" << hSocket << endl ;
onServerConnection( hSocket ) ;
}
}
else
{
cout << "- Connection received immediately ; hSocket=" << hSocket << endl ;
onServerConnection( hSocket ) ;
}
|
|
|
|
|
Hi!
I'm trying to load a docking bar stored inside a
DLL into my client app, but I just can't get it
to work. It asserts when I call the docking bar's
Create() method.
Inside the DLL, I'm doing all my work in a
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// do MFC stuff here
}
block. The docking bar works on its own. It works
if I declare and create it inside the client
instead of inside the DLL.
I guess the problem comes from the fact that
I can't get a valid CFrameWnd* to pass to the
docking bar's Create() method, and I'm not
sure how to get one.
I've tried passing a pointer to the CFrameWnd of
the client app to the DLL, but I still get that
ASSERT. I've tried passing the HWND of the client
to the DLL, and then have the DLL find the right
CFrameWnd* by calling FromHandle(), but what I
get never works either. The same ASSERT fires.
The actual ASSERT (if it's helpful to know) is
ASSERT(pMap != NULL);
At line 879 in Wincore.cpp.
Does anybody have any ideas about this?
Thanks a bunch!
Steve The Plant
|
|
|
|
|
Check the KB article Q192853: "BUG: Wincore.cpp Line 879 Assert When Using MFC Classes"
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi all.
Has anyone else ever had a problem with the VC++ resource editor giving controls, strings etc. constants with negative values in resource.h? eg, I often get an assertion because the res ed has put something in like this:
#define IDC_MYCTRL -63231
is it a known issue? is there a fix?
pls excuse me if this is an old one
NB
|
|
|
|
|
This has happened to me, only once. I have no idea why - I just made the value positive and that was it. I suspect it may have something to do with the 'next' values stored at the bottom, I don't know what the maximum value there is, but if it's not stored as an unsigned value, then it will roll over to a big negative number.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Has anyone ever done this? I'd like to basically create a software that runs on my server and clients can connect to it and conduct meetings with other clients much like webex.com.
Eventually I'd write it into an activex control, but I really don't know where to start. I've written a lot of code in my days, but I can't comprehend how to start with remote desktop sharing?
Any help would be appreciated.
Thanks,
Kevin
|
|
|
|
|
I am attempting to use a VB DLL in a C++ project (actually 2), I am rather successfull at handling BSTR but not BSTR* - specifically I need to convert any "normal" string (char*, string, CString) into a BSTR* because the DLL's functions only take BSTR*
BryanV
bryanv@factualdata.com
|
|
|
|
|