Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Stubborn Combo Box appears to ignore my LB_ADDSTRING messages.

Posted on 1997-01-07
1
Medium Priority
?
391 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 240 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

927 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