Sending IDOK to a dialogbox
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Sending IDOK to a dialogbox

  1. #1
    Join Date
    Dec 2007
    Location
    France
    Posts
    190

    Sending IDOK to a dialogbox

    I explain my problem.

    I wanna make a ticker effect in a edittext field that is in a dialogbox.
    Something like this:
    o
    lo
    llo
    ello
    Hello etc.

    Now the problem is that as long as you didnt get out of the case IDOK: you wont see anything.
    You only gonna see the (whole) last phrase printed.

    Now pure logic tells me that i should call IDOK with sendmessage in a loop.

    But if i recall it im never gonna get out of it so its an infinite loop.

    Im sure this problem has been solved already i just couldnt find it.

    Code:
    BOOL CALLBACK DlgProc2 (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)
        {
        case WM_INITDIALOG :
            return TRUE ;
        case WM_COMMAND :
            switch (LOWORD (wParam))
            {
            case IDOK :
                Scrolling(hDlg) ;
                return TRUE ;
            case IDCANCEL :
                EndDialog (hDlg, 0) ;
                return TRUE ;
            }
            break ;
        }
        return FALSE ;
    }

  2. #2
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,421

    Re: Sending IDOK to a dialogbox

    Since you didn't show the contents of your Scrolling(hDlg) function, I can only guess that you are using SetWindowText in it to first put in the "o", then the "lo", and so on.

    If so, immediately after the call to SetWindowText, add a call to the edit control's UpdateWindow() function. This will bypass the normal windows message pump and cause it to update immediately.

    Hope that helps.
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

  3. #3
    Join Date
    Dec 2007
    Location
    France
    Posts
    190

    Re: Sending IDOK to a dialogbox

    Thank you Krmed, that helped!

  4. #4
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Sending IDOK to a dialogbox

    I wonder why you were handling the IDOK command for your purposes. You better would have a static text control and output your ticker message using a timer (i. e. handling the WM_TIMER message). That way your dialog wouldn't freeze while outputting the message. You could hold the last state of your ticker in static variables of your handler function.

    Code:
    ...
        switch (message)
        {
        case WM_INITDIALOG :
              SetTimer(hDlg, 99, 500, MyTimerProc);
              return TRUE;
        ...
    
    
    void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
    {
          static int lastticker = 0;
          if (idEvent == 99)
          {
                HWND hwndTicker = GetDlgItem(hwnd, IDC_STC_TICKER);
                switch (lastticker)
                {
                  case  0: SetWindowText(hwndTicker, "o"); break;
                  case  1: SetWindowText(hwndTicker, "lo"); break;
                  case  2: SetWindowText(hwndTicker, "llo"); break;
                  case  3: SetWindowText(hwndTicker, "ello"); break;
                  case  4: SetWindowText(hwndTicker, "Hello"); break;
                }
                lastticker = (lastticker+1)%5;
          }
    }

  5. #5
    Join Date
    Dec 2007
    Location
    France
    Posts
    190

    Re: Sending IDOK to a dialogbox

    Thank you, thats what i was looking for!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center