Solved

Stubborn Combo Box appears to ignore my LB_ADDSTRING messages.

Posted on 1997-01-07
1
374 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

12 Experts available now in Live!

Get 1:1 Help Now