API Calls from Win2k and Win98
-
Hello, NOTE: This is sort of long/detailed. I know I have been asking a ton of questions lately. Thank you for all of your feedback. I have a custom-drawn listview control that does not highlight the icon while in ListView mode written. I used some of the great painting code provided by Carlos Perez in his UtiltiyLibrary. The problem I am having is that he uses some API SendMessage calls in order to get certain information from the listview. The main thing he is getting is the text of a subitem because when you use Items[1].SubItems[1] (or whatever) you get really weird results. Now the problem I am having is that it doesn't work so well on Win98/ME. I know this is because of the Unicode issue. I have my SendMessage declared as follows:
[DllImport("user32.dll", CharSet=CharSet.Auto )] public static extern void SendMessage(IntPtr hWnd, ListViewMessages msg, int wParam, ref LVITEM lParam);
Then it is called with:SendMessage(Handle, ListViewMessages.LVM_GETITEMTEXTW, row, ref lvi);
ListViewMessages.LVM_GETITEMTEXTW is defined as (LVM_FIRST + 115) This works great on Win2k. But if I run it on Win98/ME, the Text that is return into lvi is just the first letter. If I change the GETITEMTEXTW to (LVM_FIRST + 45), it will work prefectly on Win98/ME but it does not work correctly on Win2k (just get black bars). I have tried changing the CharSet and making EntryPoint="SendMessageA" on the DLLImport, but nothing works. I have a few other SendMessage calls too that use the Unicode message and I'm afraid that they won't work either. I have a list of the non-unicode messages, I just need to know to use the same message number is both the Win2k and 98/ME version. Thanks for reading this really long message. Jonathan -
Hello, NOTE: This is sort of long/detailed. I know I have been asking a ton of questions lately. Thank you for all of your feedback. I have a custom-drawn listview control that does not highlight the icon while in ListView mode written. I used some of the great painting code provided by Carlos Perez in his UtiltiyLibrary. The problem I am having is that he uses some API SendMessage calls in order to get certain information from the listview. The main thing he is getting is the text of a subitem because when you use Items[1].SubItems[1] (or whatever) you get really weird results. Now the problem I am having is that it doesn't work so well on Win98/ME. I know this is because of the Unicode issue. I have my SendMessage declared as follows:
[DllImport("user32.dll", CharSet=CharSet.Auto )] public static extern void SendMessage(IntPtr hWnd, ListViewMessages msg, int wParam, ref LVITEM lParam);
Then it is called with:SendMessage(Handle, ListViewMessages.LVM_GETITEMTEXTW, row, ref lvi);
ListViewMessages.LVM_GETITEMTEXTW is defined as (LVM_FIRST + 115) This works great on Win2k. But if I run it on Win98/ME, the Text that is return into lvi is just the first letter. If I change the GETITEMTEXTW to (LVM_FIRST + 45), it will work prefectly on Win98/ME but it does not work correctly on Win2k (just get black bars). I have tried changing the CharSet and making EntryPoint="SendMessageA" on the DLLImport, but nothing works. I have a few other SendMessage calls too that use the Unicode message and I'm afraid that they won't work either. I have a list of the non-unicode messages, I just need to know to use the same message number is both the Win2k and 98/ME version. Thanks for reading this really long message. JonathanTo Answer my question for the benefit of others. From the information that I gave, it was probably practically impossible to answer. It appears that my structure that I had for LV_ITEM had CharSet.Auto set on it. I removed it so that it would be CharSet.Ansi therefore everything concerning converting between ansi and unicode would be taken care of on NT/2000/XP machines. That solved my problem once I set the Messages to be the non-unicode veresion.