Solved

Stubborn Combo Box appears to ignore my LB_ADDSTRING messages.

Posted on 1997-01-07
1
376 Views
Last Modified: 2013-12-03
I have been attempting to insert five strings into a combo box, to no avail.  Not only do the strings not display, but my DBWin app reports "err DLG_LBOX 02AF:B39F: Invalid string pointer: 0000:0000".  Here is the dialog procedure I'm using:

/* Start of C Code */
BOOL FAR PASCAL MainDlgProc(HWND hDlg, UINT msg, WPARAM wP, LPARAM lP)
{
    switch (msg)
    {
        case WM_INITDIALOG:
        {
            HWND hwLBox;
            DWORD dwRet;
            int i;

            LPSTR prgNames[5]={"File Manager", "Character Map", "Windows Help", "Solitaire", "Minesweeper"};

            hwLBox=GetDlgItem(hDlg, IDL_PROGS);
            if(hwLBox==NULL)
                MessageBox(NULL, "Debugging message number 0 inserted in \"DLG_LBOX.C\" on 05-Jan-1997 at 12:18:05", "Debugging Message...", MB_APPLMODAL|MB_ICONINFORMATION|MB_OK);
            dwRet=SendMessage(hwLBox, LB_RESETCONTENT, 0, 0L);
            if(dwRet==LB_ERR)
                MessageBox(NULL, "Debugging message number 1 inserted in \"DLG_LBOX.C\" on 04-Jan-1997 at 11:54:57", "Debugging Message...", MB_APPLMODAL|MB_ICONINFORMATION|MB_OK);
            for(i=0;i==4;i++)
                SendMessage(hwLBox, LB_ADDSTRING, 0, (LPARAM)(LPSTR)prgNames[i]);
            return FALSE;
            }
            break;

        case WM_COMMAND:
            switch(wP)
            {
                case IDB_EXECUTE:
                {
                    HWND hwLBox;
                    DWORD dwIndex;

                    hwLBox=GetDlgItem(hDlg, IDL_PROGS);
                    dwIndex=SendMessage(hwLBox, LB_GETCURSEL, 0, 0);

                    if(dwIndex==0)
                        WinExec("WINFILE.EXE", 1);
                    if(dwIndex==1)
                        WinExec("CHARMAP.EXE", 1);
                    if(dwIndex==2)
                        WinExec("WINHELP.EXE", 1);
                    if(dwIndex==3)
                        WinExec("SOL.EXE", 1);
                    if(dwIndex==4)
                        WinExec("WINMINE.EXE", 1);
                    if(dwIndex!=LB_ERR)
                        DestroyWindow(hDlg);
                    else
                    {
                        MessageBeep(MB_ICONHAND);
                        MessageBox(hDlg, "Please select a program from the listbox before selecting execute.\0", "Please make a selection...\0", MB_APPLMODAL|MB_ICONHAND|MB_OK);
                    }
                }
                break;
            }
        break;

        case WM_DESTROY:
        {
            HWND hwLBox, hwUnused;

            hwLBox=GetDlgItem(hDlg, IDL_PROGS);
            SendMessage(hwLBox, LB_RESETCONTENT, 0, 0L);
            PostQuitMessage(0);
        }
        break;

        default:
            return FALSE;
            break;
    }
    return TRUE;
}

/* End Code */

So, things appear to be okay.  I've tried just about everything I can think of, including sending each string as a literal using two casts (LPARAM and LPSTR) to send it.  I am going crazy!  If you can give me any help it would be appreciated.  Thank you.

                 Steven Spain
                 SJSME@IX.NETCOM.COM
0
Comment
Question by:sjsme
1 Comment
 

Accepted Solution

by:
msaraiva earned 120 total points
ID: 1298601
Have you tried, instead of SendMessage, PostMessage ?

/* ... */
for(i=0;i==4;i++)
  PostMessage( hwLBox, LB_ADDSTRING, 0, (LPARAM)(LPSTR)prgNames[i]);
/* ... */
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dir function fails on mapped drives 28 123
Example of WebAPI 7 32
How and where to get Business Intelligence Development Studio? 2 77
Trouble with References... 5 44
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now