Solved

Stubborn Combo Box appears to ignore my LB_ADDSTRING messages.

Posted on 1997-01-07
1
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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