|
Now I'm unsure. I *think* my system settings is ISO 8859-1[5], but I'm not sure. It could also be CP-1252. Argh. I think I'll return to this problem on monday. My brain wants to go home...
|
|
|
|
|
Joergen Sigvardsson wrote: My brain wants to go home...
Let your brain go home, as long as the rest of you stays at work.
Everyone knows that the real programming is in the fingers, anyway.
Software Zen: delete this;
|
|
|
|
|
Hello Friends,
In one of my application. I am using HOTKey. But getting problem. as it doesn't show any problem it is not working too.
I am using it as follow:
case WM_INITDIALOG:
{
ShowWindow(hWndDlg,SW_HIDE);
InitCommonControls();
HWND hHotKey = GetDlgItem(hWndDlg,IDC_HOTKEY1);
if(!RegisterHotKey(hHotKey , 100, MOD_ALT | MOD_CONTROL, 's'))
{
dError = GetLastError();
}
}
break;
case WM_HOTKEY:
ShowWindow(hWndDlg,SW_SHOW);
break;
I know I am doing some silly mistake. But don;t know where. Please help me if you know.
|
|
|
|
|
GauranG33 wrote: if(!RegisterHotKey(hHotKey , 100, MOD_ALT | MOD_CONTROL, 's'))
The last parameter is the virtual key code.
For key 's', its 0x53 or 'S'.
I think this is the problem.
|
|
|
|
|
I have made the changes as you have suggested.But still there is a problem.
The Hot key combination works only when the focus is on that window. while my application is runing in the background( Its a Win32 dialog based application and i make dialog hidden at startup)and so the Hot key is not working. Is there any way I can solve this.
I am using something like this now,
LRESULT CALLBACK MyDialogProc(HWND hWndDlg,....)
{
ShowWindow(hWndDlg,SW_HIDE);
switch(message)
{
case WM_INITDIALOG:
{
InitCommonControls();
HWND hHotKey = GetDlgItem(hWndDlg,IDC_HOTKEY1);
if(!RegisterHotKey(hWndDlg , IDC_HOTKEY1, MOD_ALT | MOD_CONTROL,0x67))
{
dError = GetLastError();
MessageBox(NULL,L"Hot Key Not Working ",L"Error",0);
}
}
break;
case WM_HOTKEY:
ChangeString(hWndDlg);
break;
}
}
|
|
|
|
|
You are passing the HWND of the control to the RegisterHotKey API command - so that is where the WM_HOTKEY message will end up.
Try:
if(!RegisterHotKey(hWndDlg, 100, MOD_ALT | MOD_CONTROL, 's'))
Also looking at the reference for the command: "To avoid conflicts with hot-key identifiers defined by other shared DLLs, a DLL should use the GlobalAddAtom function to obtain the hot-key identifier." I don't know if this will be true for you.
Iain.
|
|
|
|
|
I have made the changes as you have suggested.But still there is a problem.
The Hot key combination works only when the focus is on that window. while my application is runing in the background( Its a Win32 dialog based application and i make dialog hidden at startup)and so the Hot key is not working. Is there any way I can solve this.
I am using something like this now,
LRESULT CALLBACK MyDialogProc(HWND hWndDlg,....)
{
ShowWindow(hWndDlg,SW_HIDE);
switch(message)
{
case WM_INITDIALOG:
{
InitCommonControls();
HWND hHotKey = GetDlgItem(hWndDlg,IDC_HOTKEY1);
if(!RegisterHotKey(hWndDlg , IDC_HOTKEY1, MOD_ALT | MOD_CONTROL,0x67))
{
dError = GetLastError();
MessageBox(NULL,L"Hot Key Not Working ",L"Error",0);
}
}
break;
case WM_HOTKEY:
ChangeString(hWndDlg);
break;
}
}
|
|
|
|
|
Well, that looks like it should be OK... But maybe it only works with top level windows? Do you get an error when the command is called?
Try using Spy++ to see if the WM_HOTKEY message is sent to any window in your app.
Try using the m_hWnd of the top level window (Usually AfxGetMainWnd () in MFC - but if you're using Win32 then you probably already know it).
Then try Spy++ again.
Iain.
|
|
|
|
|
What I need to do is have a C++ DLL send messages to a VB6 Program window and get back data (long and double) that is in the VB Code. I can get the handle to the window using FindWindow and send messages to it but I'm having problems getting the data back from the VB6 program without getting callback timeouts. Keep in mind the DLL currently creates a CDialog window to handle the communication between the two since the program that is calling the DLL is third party software from Aerotech that can use functions in C++ DLLs to perform functions that it can't do internally. Execution speed of the DLL functions are important so I would like to stay away from using I/O files to pass the data.
Thanks,
George
|
|
|
|
|
|
Thanks for trying to help but not what I'm trying to do. I'm calling a function in the DLL from a third party software, the function then sends a message to a different program, written in VB6, and waits for that program to reply. The way it was written when I got the code was the VB6 code was sending a message (using SendMessage) back to the DLL that called the VB6 code. Now if I understand Windows correctly it will never finish because neither SendMessage will return because the last SendMessage won't be processed until the DLL responds to it and the DLL won't read it until the VB6 code responds to the initial SendMessage.
ie. Software1 ----> DLL ----> Software2(VB6) -----> DLL -----> Software1
Does that explain it better? I've looked at using the WPARAM and LPARAM but can't find how to use them in VB6 because it looks like they are only passed by value. Maybe setting some shared variables in the DLL and having both programs access the variables.
George
|
|
|
|
|
How can I get previous window who had the focus when my app is activated?
Thanks!
|
|
|
|
|
afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );
pWndOther
Pointer to the CWnd being activated or deactivated. The pointer can be NULL, and it may be temporary.
if not using MFC...
WM_ACTIVATE
fActive = LOWORD(wParam); // activation flag
fMinimized = (BOOL) HIWORD(wParam); // minimized flag
hwndPrevious = (HWND) lParam; // window handle
|
|
|
|
|
But I tried that already:
void CDialList::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) <br />
{<br />
CDialog::OnActivate(nState, pWndOther, bMinimized);<br />
if(nState == WA_INACTIVE)<br />
{<br />
if(my_pOldWnd)<br />
my_pOldWnd->SetActiveWindow();<br />
OnCancel();<br />
}<br />
if(nState == WA_ACTIVE)<br />
my_pOldWnd = pWndOther;<br />
}
But on state when my app is activated (WA_ACTIVE) I get pointer to my app. and not to window being inactivated(previous active wnd)!?
|
|
|
|
|
Try this then
afx_msg void OnSetFocus( CWnd* pOldWnd );
if not using MFC...
WM_SETFOCUS
hwndLoseFocus = (HWND) wParam; // handle to window losing focus
|
|
|
|
|
What about WM_ACTIVATEAPP?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think the problem is in fact that my app is placed on system tray! That is why I always get pointer to my app as previous, I think when my app activate first it activate system tray and then my dialog!
|
|
|
|
|
Hi,
Why am getting this exception
KERNEL32! 7c59bcb1()
MSVCRTD! _CxxThrowException@8 + 57 bytes
COleDispatchDriver::InvokeHelperV(long 26, unsigned short 2, unsigned short 12, void * 0x053afeac, const unsigned char * 0x00000000, char * 0x053afe60) line 407
COleControlSite::InvokeHelperV(long 26, unsigned short 2, unsigned short 12, void * 0x053afeac, const unsigned char * 0x00000000, char * 0x053afe60) line 976
CWnd::InvokeHelper(CWnd * const 0x0042a5a8 {CMSComm hWnd=0x00c302f0}, long 26, unsigned short 2, unsigned short 12, void * 0x053afeac) line 354
CMSComm::GetInput() line 347 + 21 bytes
CNgpptDialog::SerialDataUpdate() line 613 + 15 bytes
ReadResponse() line 171
KERNEL32! 7c57b3bc()
Thanks
|
|
|
|
|
shir_k wrote: Why am getting this exception
KERNEL32! 7c59bcb1()
MSVCRTD! _CxxThrowException@8 + 57 bytes
COleDispatchDriver::InvokeHelperV(long 26, unsigned short 2, unsigned short 12, void * 0x053afeac, const unsigned char * 0x00000000, char * 0x053afe60) line 407
COleControlSite::InvokeHelperV(long 26, unsigned short 2, unsigned short 12, void * 0x053afeac, const unsigned char * 0x00000000, char * 0x053afe60) line 976
CWnd::InvokeHelper(CWnd * const 0x0042a5a8 {CMSComm hWnd=0x00c302f0}, long 26, unsigned short 2, unsigned short 12, void * 0x053afeac) line 354
CMSComm::GetInput() line 347 + 21 bytes
CNgpptDialog::SerialDataUpdate() line 613 + 15 bytes
ReadResponse() line 171
KERNEL32! 7c57b3bc()
Because the MSCOMM control doesn't seem to be happy with the parameters it is provided.
I don't know what version of the control you're using, but since IMSComm is a published dual interface, it should not have changed.
By looking at the parameters provided to CWnd::InvokeHelper() it seems like you're calling the Input method (long 26 ) as a DISPATCH_PROPERTYGET (unsigned short 2 ) and expecting a VARIANT in return (unsigned short 12 ).
If you still want to use the MSCOMM control I suggest you declare a VARIANT and set it up prior to calling the control.
Create a SAFEARRAY with SafeArrayCreate() containing an array of unsigned char (VT_UI1) , let the pArray member of the VARIANT union point to the safearray and set the vt member of the VARIANT to VT_UI1 | VT_ARRAY .
Look up the documentation for SafeArrayCreate() in MSDN and you'll find how to set it up.
If you're willing to give the MSCOMM control up (since it's really bad in many ways) and do the serial communication yourself, which I really urge you to, you should have a look at this[^] great article.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
hi,
This how am getting data from serial port
CString SerialData
CComVariant vIn;
vIn.Clear();
vIn = CMSCommPtr ->GetInput();
SerialData = vIn.bstrVal;
U see any problem in the above code.
|
|
|
|
|
shir_k wrote: CString SerialData
CComVariant vIn;
vIn.Clear();
vIn = CMSCommPtr ->GetInput();
SerialData = vIn.bstrVal;
U see any problem in the above code.
All COM interfaces returns a HRESULT, which is a 32-bit integer value that is an error code that equals zero if everything was OK. The ability to return any other type is disguised when using dispatch interfaces. In your case the VARIANT that is supposed to be returned is a temporary object in the wrapper for the MSComm server. The wrapper was created by the wizard when you added the ActiveX component to your project. A pointer to this temporary VARIANT is provided in the parameter list when the interface method is called. For some reason the MSComm server doesn't like how that temporary object is set up, or you may be calling it from the wrong context.
This can happen if you're calling the server from a different thread than the one that created the server without marshalling the interface.
I suggest that you continue with one of the following depending on whether you're using multiple threads or not:
1. If you're using multiple threads you have to know how to cross apartment boundaries the correct way. Read Lim Bio Liong's excellent articles to get the basics down. You'll find them here[^], starting with part 1.
2. If you're only using one single thread, I suggest you use the other implementation of the Input() method that takes a VARIANT in the parameter list according to my first post in this forum thread. This way you have the control over the VARIANT.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Ok Thanks
Ours is multi threaded.I will go through the article.
Our project gets hanged or crashed when i try to any multi media or graphics related file.
Thanks
|
|
|
|
|
Um, it might help if you said *when* you get that exception, and in what context?
Does it appear on the LCD screen on your toothbrush when you use it?
Is it on your toaster? Only when you try and heat poptarts?
Iain.
|
|
|
|
|
Pop-Tart exceptions are UNACCEPTABLE!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Am placing the pressure data continously in CListCtrl after reading from serial port(Am reading every 10 ms with the help of timer).Am also deleting data placed in CListCtrl after displaying 150 pressure outputs on the control(am deleting only one data using m_ctrl.delete(0)) so buffer does not overflow.
Flow of the program is
1) Timer interrupt occurs every 10 ms
2)Read the serial port and place it in CListCtrl at every 10 ms.
This is working for some time lated above exception occurs.
|
|
|
|