|
mr_m_imran wrote: i saw someone mentioning CImage somewhere but it's nowhere on the MSDN.
You must've been looking on that *other* MSDN:
http://msdn2.microsoft.com/en-us/library/bwea7by5(VS.80).aspx[^]
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thanks, David. you're right. i was looking at the (NON-ATL) MFC...
|
|
|
|
|
If you want to use CImage its easy to use.
|
|
|
|
|
Is it just me, or is there no way to do a direct conversion from ANSI to UTF8 in one call? Currently, I'm converting from ANSI to UTF16, and then from UTF16 to UTF8 (MultiByteToWideChar et al). That's rather clumbsy...
|
|
|
|
|
What about the A2W() macro?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
That macro converts to UTF16 (through MultiByteToWideChar()). Basically, I'm doing WideCharToMultiByte(MultiByteToWideChar()). One call too much for my taste.
|
|
|
|
|
A2W() is an indirect wrapper around MultiByteToWideChar() . W2A() is an indirect wrapper around WideCharToMultiByte() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If by "ANSI" you mean ISO 8859-1, the nice thing is that it corresponds to Unicode code points, so you can simply "widen" them and convert to utf-8 directly (I recommend my utf8-cpp library for that )
If, on the other hand, by "ANSI" you mean Windows CP-1252 there is an area where it differs from Unicode, so you would need to map these characters first.
|
|
|
|
|
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!
|
|
|
|