|
|
Does anyone know how to pass a CRecordset pointer thro the clipboard to another application? I am able to pass the pointer using Global memory but the database handle gets screwed up.
|
|
|
|
|
I don't know what you mean with Global memory, as in Win32 you can't access memory owned by other processes. Anyway, you can't pass a pointer to an object to another process, as your application will crash when it tries to use it. Furthermore, you shouldn't pass a pointer to a CRecordset from one thread to another, as many of the CObject derived classes store data in the Thread Local Storage, and your app will crash after some time of well working.
Sorry for my English!
|
|
|
|
|
If you create a shared data segment in a DLL, then you CAN access and share memory among multiple processes in Win32.
Typically, these variables have constant lifetime - the entire time the DLL is loaded by any process.
I have not found a way to make 'dynamically allocated' shared memory available, however, without using memory mapped files.
The way I send data back and forth among threads is to create a data structure that contains the relevant data. Pass the pointer to the data structure to the other thread, and the object should have a member function or else a constructor that can accept a pointer to the data structure for copying the data to itself. So you have this assignment step, which is generally safe, it is just the CObject part of the object that usually does not transfer well among threads.
|
|
|
|
|
I need to disable the CD rom drive during my app runtime.
Does anybody know how can i do it without rebooting? Is there an API call or a registry key to set?
Thanks in advance
|
|
|
|
|
I want to write VxD to access the PCI Card. can anyone help me in DDK usage with Visual C++ 6.0.
if you can tell me the URLs from where i can get something for VxD writing.
|
|
|
|
|
I have created an image list with ILC_COLOR32.It is working propertly when my system supports 16777216 colors.When I change color support to 65536 colors, nothind is displayed.In this case case, the image list ceation is success, but Add() and Draw() fails.
|
|
|
|
|
Hi,
I am experiencing some strange problems. I am getting a whole bunch of access violations when I run
my program. The program doesn't crash but in the debug window you can see about 200 access violation
messages. I tracked this down to CMainFrame::OnCreate(). Infact, all of these access violations occur
at the point where the CToolBar's CreateEx function get called. Here is what App Wizard created for
my project for the CToolBar,
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
The Toolbar get created, but with a whole bunch of access violations along the way. Another thing,
this doesn't happen all the time. I would guess three out of five times I run the program, I get all of these
access violations. Anyway, I hope someone know why this is happening. I would really appreciate the help. Just in case someone was interested, here is a look at what the violation message looks like
First-chance exception in Plas.exe (GDI32.DLL): 0xC0000005: Access Violation.
Thanks
|
|
|
|
|
I don't know if this is the case, but I experieced some problems with AppWizard generated applications if they had a Toolbar but not a StatusBar, because even if I unselected the StatusBar in the Wizard page, some generated code still made use of it. Don't know why, but it's true.
It seems, however, that your problem is a little different. You wrote of the toolbar creation, so I thought of my past troubles with it.
Cheers,
Paolo
|
|
|
|
|
I am surprised that your program continues to run after an access violation. Perhaps VC 6 has something new for debugging that allows a program to continue execution in spite of an access violation; if so, I would not know about it since I still use VC 5. You might check to see if it is possible to get the debugger to stop when an access violation occurs. If you can do that then you can look at the stack and you might get a good indication of the problem.
Are you sure you are working with a debug version of your program? You should, if you are getting errors like that.
|
|
|
|
|
When you get your access violation don't cancel let it go into the debugger and look thru call stack window
and start putting break points in in only the cpp's that you made not the one's from MS.
|
|
|
|
|
sspcmp:
Unless your reply is relevant to my reply, you should reply to the question instead of my reply. I received notification of your reply by email but I already know how to use the debugger.
|
|
|
|
|
Hi, I am stuck...
We use a custom control (yes, THE Grid Control in a big project .
With NT4 everything is running fine, but now someone dared to run it with Win98 and W2k.
The Result: every dialog with the grid in it refused to open!!!
The samples provided with the grid run fine on the same machine, so it is nothing with the grid.
When I setl the custom control in the resource editor to the classname EDIT, the dialog starts (but it looks terrible, of course .
So: what can be wrong in this project?
ANY hints?
Martin
|
|
|
|
|
Did you try to recompile the code under w98 ? I have experienced some similar problems - I can't run the programm compiled in NT under 98 , but the programm compiled under 98 it works fine on both NT & 98.I think some links aren't good ....
|
|
|
|
|
Yes, I tried it, but with no success.
In the meantime I got another hint:
The dialogs don't load when I put the ressources into an external DLL (as it is the case in this project)!
Is there a way to tell the application, that it has to run with such an external DLL AND custom controls?
Did I miss something important to do? Every other dialog works just fine, only the dialogs with custom controls in it refuse to load...
Martin
|
|
|
|
|
Hi, I've got it!!!
When using an external DLL, you have to register the window class for THAT DLL!
So you have to set the hInst of the WNDCLASS-structure via AfxGetResourceHandle() instead of AfxGetInstanceHandle() as it is done most of the time...
Happy greetings, Martin
|
|
|
|
|
Hi, I am stuck...
We use a custom control (yes, THE Grid Control in a big project .
With NT4 everything is running fine, but now someone dared to run it with Win98 and W2k.
The Result: every dialog with the grid in it refused to open!!!
The samples provided with the grid run fine on the same machine, so it is nothing with the grid.
When I setl the custom control in the resource editor to the classname EDIT, the dialog starts (but it looks terrible, of course .
So: what can be wrong in this project?
ANY hints?
Martin
|
|
|
|
|
here is a Shot in the Dark. hope it may be help.
Don't use the Default name for the dialogs controls
i.e
When the Control's ID is IDC_STATIC I used to have weird problems of th dialog not showing in . or the control it self not being used win98 fine when using nt.
(I guess because the value for, IDC_STATIC is = -1 in win95 , which can't be used
Try changing the ID of the control to somthing Diffrent. like IDC_MYCONTROL. (geee, that was imaginitive of me )
Cheers
Alfadhly
|
|
|
|
|
Thanks, Alfadhly,
but that's not the point, all the controls have other IDs.
In the meantime I got another hint:
The dialogs don't load when I put the ressources into an EXTERNAL DLL (as it is the case in this project)!
You can do this with a minimal test app and you will get the same problems!
Is there a way to tell the application, that it has to run with such an external DLL AND custom controls?
Did I miss something important to do? Every other dialog works just fine, only the dialogs with custom controls in it refuse to load...
Martin
|
|
|
|
|
Hi, I am stuck...
We use a custom control (yes, THE Grid Control in a big project .
With NT4 everything is running fine, but now someone dared to run it with Win98 and W2k.
The Result: every dialog with the grid in it refused to open!!!
The samples provided with the grid run fine on the same machine, so it is nothing with the grid.
When I setl the custom control in the resource editor to the classname EDIT, the dialog starts (but it looks terrible, of course .
So: what can be wrong in this project?
ANY hints?
Martin
|
|
|
|
|
hi,
I use CreateProcess to execute an application from within my code.
i want to simulate menu item clicks in the application from within my code.
I presume this can be done using SendMessage where i pass
the appropriate menu id as the loword of wparam
But how do i get the window handle from?
i just have the process id that was returned by CreateProcess
Thanks in advance,
Gita
|
|
|
|
|
You can enumerate all the top level windows, then call GetWindowThreadProcessId on each one until you find the same process id. However you can't say if it's the only top level window created by that process.
Try code like this:
<br />
#define TIMEOUT 20*1000<br />
<br />
struct ProcessWindow<br />
{<br />
DWORD processID;<br />
DWORD threadID;<br />
HWND hwnd;<br />
};<br />
<br />
static BOOL CALLBACK EnumWindowsProc(<br />
HWND hwnd,
ProcessWindow *lParam
)<br />
{<br />
DWORD processID = NULL;<br />
DWORD threadID = GetWindowThreadProcessId(hwnd, &processID);<br />
<br />
if (processID == lParam->processID && threadID == lParam->threadID)<br />
{<br />
lParam->hwnd = hwnd;<br />
return FALSE;
}<br />
<br />
return TRUE;<br />
}<br />
<br />
HWND StartApp(LPCTSTR path)<br />
{<br />
STARTUPINFO si;<br />
ZeroMemory(&si, sizeof(STARTUPINFO));<br />
<br />
si.cb = sizeof(STARTUPINFO);<br />
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;<br />
si.wShowWindow = SW_HIDE;<br />
<br />
PROCESS_INFORMATION pi;<br />
<br />
TCHAR buf[MAX_PATH];<br />
lstrcpyn(buf, path, MAX_PATH);<br />
<br />
if (!CreateProcess(NULL, buf, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE |<br />
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))<br />
return NULL;<br />
<br />
if(WaitForInputIdle(pi.hProcess, TIMEOUT) != 0)<br />
return NULL;<br />
<br />
<br />
ProcessWindow pw;<br />
pw.hwnd = NULL;<br />
pw.processID = pi.dwProcessId;<br />
pw.threadID = pi.dwThreadId;<br />
<br />
if (EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)(LPVOID)&pw))<br />
return NULL;<br />
<br />
return pw.hwnd;<br />
}<br />
I've used it with success. I hope it will work also for you.
Cheers,
Paolo.
|
|
|
|
|
I have an SDI MFC application. I've created the UI similar to the MSDN with a tab control in the left splitter and then in the right I have ActiveX controls and such that the user interacts with. Now, when the user for instance goes to the 'Contents' tab and opens one of the items I want to create a dynamic splitter to show that information. I don't however want to destroy the control in the other splitter window. So, basically when they select an item in the 'Contents' tab it sets the controls window to a size of zero and sets the other page to full size. The problem I have is closing the contents item and redisplaying the control window. I wanted to do something like an MDI where the user can click on the close button and it will set the contents to a size of zero and set the control to full size. Can anyone shed some light on if it's possible to place an MDI type close button in an SDI application?
Thanks for any help,
Craig
|
|
|
|
|
Hello, I'm a novice VC++ developer that would like to know how to change the background color of an edit control that has been marked as read-only.
Thank you in advance.
|
|
|
|
|
I think you want to override WM_CTLCOLOR for read-only edit controls the same as for other edit controls. There are some Microsoft Knowledge Base articles about it.
I know that the CodeGuru web site has some articles about changing colors and I assume that the CodeProject does too. Also see the MFC technical article "TN062: Message Reflection for Windows Controls" for an example.
See the bottom of http://home.socal.rr.com/samhobbs/Technical/ for my little description of the Microsoft Knowledge Base. You probably have a copy of the Knowledge Base that was provided with Visual C++ but I do not know if it is. Perhaps it is only supplied with the MSDN. In step 1, select "Visual C++". In step 2, use the default (keyword search using all words). In step 3 ("My Queston is"), enter "WM_CTLCOLOR".
|
|
|
|