UNICODE STRING IN one col of LISTCTRL
-
Hi all, I want have DLG application, which is not compiled with _UNICODE ( means it is not UNICODE ,right?). In that I am having one list control to display certaing strings. In perticular, I want to display strings in UNICODE (WCHAR) in say 2nd col of list ctrl for all rows, Is it possible to do this anyhow? Without compiling application to as unicode!!! Any suggestion? Jetli Constant Thing In World Is Change.
-
Hi all, I want have DLG application, which is not compiled with _UNICODE ( means it is not UNICODE ,right?). In that I am having one list control to display certaing strings. In perticular, I want to display strings in UNICODE (WCHAR) in say 2nd col of list ctrl for all rows, Is it possible to do this anyhow? Without compiling application to as unicode!!! Any suggestion? Jetli Constant Thing In World Is Change.
This is tricky but you can actually mix unicode and ansi windows within an Application. When you define _UNICODE all the macros get mapped their *W functions. So SendMessage becomes SendMessageW, etc. Windows converts between unicode and ansi between windows your behalf so that if you call SetWindowText from an ansi program to a unicode program, the recieving program will get unicode from the ansi that the sender sent. Windows tells if a window is unicode or not by how it was created. So RegisterClassA would be an window procedure expecting ansi and RegisterClassW excepts unicode. You can change this by calling SetWindowLongPtrW and passing GCLP_WNDPROC with a new WndProc. Make sure to end your new WndProc with CallWindowProcA because the original accepts ansi. This will however make the entire control unicode. If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing.
-
This is tricky but you can actually mix unicode and ansi windows within an Application. When you define _UNICODE all the macros get mapped their *W functions. So SendMessage becomes SendMessageW, etc. Windows converts between unicode and ansi between windows your behalf so that if you call SetWindowText from an ansi program to a unicode program, the recieving program will get unicode from the ansi that the sender sent. Windows tells if a window is unicode or not by how it was created. So RegisterClassA would be an window procedure expecting ansi and RegisterClassW excepts unicode. You can change this by calling SetWindowLongPtrW and passing GCLP_WNDPROC with a new WndProc. Make sure to end your new WndProc with CallWindowProcA because the original accepts ansi. This will however make the entire control unicode. If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing.
Many thanks for valuable reply. Mark Petrik Sosa wrote: If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing. Can u spread more lights on this.... Any sample how to do this.... And also after doing some look-search i found that if i call directly SendMessageW(). in that we pass Unicode params... i want to know whcih message internally passed when we call BOOL CListCtrl::SetItemText( int nItem, int nSubItem, LPTSTR lpszText ); Can this be done like this??? Thanks in advance. Jetli Constant Thing In World Is Change.
-
Many thanks for valuable reply. Mark Petrik Sosa wrote: If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing. Can u spread more lights on this.... Any sample how to do this.... And also after doing some look-search i found that if i call directly SendMessageW(). in that we pass Unicode params... i want to know whcih message internally passed when we call BOOL CListCtrl::SetItemText( int nItem, int nSubItem, LPTSTR lpszText ); Can this be done like this??? Thanks in advance. Jetli Constant Thing In World Is Change.
SetItemText is just a wrapper for LVM_SETITEMTEXT, which will be sent using SendMessageA because _UNICODE is not set. Be aware however that even if you send "unicode" messages to a window, windows will automatically convert them to ansi if the window is not unicode window. There are no samples that I know of, the easiest thing would be just to make the entire application unicode.
-
SetItemText is just a wrapper for LVM_SETITEMTEXT, which will be sent using SendMessageA because _UNICODE is not set. Be aware however that even if you send "unicode" messages to a window, windows will automatically convert them to ansi if the window is not unicode window. There are no samples that I know of, the easiest thing would be just to make the entire application unicode.
Many thanks. I will look for that. Jetli Constant Thing In World Is Change.