Need help With Scrolling Text - Wanna make Dialog Credits...

This is a discussion on Need help With Scrolling Text - Wanna make Dialog Credits... within the Windows Programming forums, part of the Platform Specific Boards category; Hi mates, jep, this is my 1 post here... great resource. I've try to find some pure api (NO MFC) ...

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    10

    Need help With Scrolling Text - Wanna make Dialog Credits...

    Hi mates,

    jep, this is my 1 post here... great resource.

    I've try to find some pure api (NO MFC) example for simple
    scrolling text in my own dialog credits... i want compile it
    with LCC, then i need it in pure api.

    I've only found mfc source example but none in pure api.

    I need to scroll text into a small dialog about box...
    someting like this:
    http://www.codeproject.com/bitmap/scrollingcredits.asp

    Please if someone can help me...
    very appreciated

    TNX


  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,668
    The easy solution that isn't as fancy as the link you provided is just use an edit box. You can make the edit box disabled and without a border and it will "blend in" with the rest of the dialog (if that's desired). All you have to do then is populate the edit box (WM_SETTEXT) and scroll the edit box (EM_LINESCROLL) on a timer.

    The fancy solution will require some basic GDI know-how. For flicker-free smooth scrolling, you'll want to use a memory DC that gets bit-blitted to the paint DC.
    This article should cover the neccessary know-how for the facny solution.

    gg

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    10
    Tnx mate

    If i use an EditBox (EDITTEXT ?) i must use EM_LINESCROLL ...
    the it scroll 1 LINE. but if i want scroll 1 or 2 pixel ?

    Lemme see your link...

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,668
    If you want pixel by pixel scrolling, then you'll have to use GDI solution.

    gg

  5. #5
    Registered User
    Join Date
    Feb 2004
    Posts
    10
    oki... i'll try to do...

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Here's something to start with. Usage code in attached zip. Flicker, etc are left up to you to deal with as described in link by Codeplug.

    Code:
    static LRESULT CALLBACK ScrollerProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
    	{
    
    		case WM_CREATE:
    			return 0;
    
    		case WM_DESTROY:
    			return 0;
    
    		case WM_VSCROLL:
    			SetWindowLong(hwnd, 0, wParam);   /* Save scroll position provided in wParam */
    			InvalidateRect(hwnd, NULL, TRUE);
    
    		case WM_PAINT:
    		{
    			PAINTSTRUCT ps;
    			RECT rc;
    			TCHAR szWndText[8192];
    
    			GetClientRect(hwnd, &rc);
    			rc.top -= GetWindowLong(hwnd, 0);  /* Move top of text up by scroll position */
    
    			GetWindowText(hwnd, szWndText, 8192);
    
    			BeginPaint(hwnd, &ps);
    
    				DrawText(ps.hdc, szWndText, lstrlen(szWndText), &rc, DT_CENTER);
    
    			EndPaint(hwnd, &ps);
    
    			return 0;
    		}
    	}
    
    	return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    
    
    BOOL ScrollerRegister(void)
    {
    	WNDCLASSEX wc = { 0 };
    
    	wc.cbSize        = sizeof (WNDCLASSEX);
    	wc.style         = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    	wc.cbClsExtra    = 0;
    	wc.cbWndExtra    = sizeof(LONG); /* Room to save scroll position */
    	wc.hInstance     = GetModuleHandle(NULL);
    	wc.lpfnWndProc   = ScrollerProc;
    	wc.hIcon         = NULL;
    	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
    	wc.lpszMenuName  = NULL;
    	wc.lpszClassName = SCROLLER_CLASS;
    	wc.hIconSm       = NULL;
    
    	return RegisterClassEx(&wc);
    }
    
    
    BOOL ScrollerUnregister(void)
    {
    	return UnregisterClass(SCROLLER_CLASS, GetModuleHandle(NULL));
    }
    Attached Files Attached Files

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    two other solutions are

    ScrollDC() or a listveiw with the 'ensure visible' style.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #8
    Registered User
    Join Date
    Feb 2004
    Posts
    10

    Jep

    TNX mates

    Now i've understand exactly how to... isn't same as moving layers... i must draw & formatting the text every time i move it...

    oki...

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,668
    You should be able to create and render the text in one large off screen DC. Then the scrolling is achieved by bit-blit'ing a "window" of the off screen DC.

    gg

  10. #10
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Maybe you could put the text in a static control and just move it up on the timer interval.

  11. #11
    Registered User
    Join Date
    Feb 2004
    Posts
    10
    Originally posted by anonytmouse
    Maybe you could put the text in a static control and just move it up on the timer interval.
    this is another good idea...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamically add statis text to a dialog box
    By earth_angel in forum Windows Programming
    Replies: 8
    Last Post: 06-23-2005, 01:28 PM
  2. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 04:33 PM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. how to make 2 text window
    By bluexrogue in forum C Programming
    Replies: 2
    Last Post: 09-15-2001, 08:51 PM
  5. How do I make a text box??
    By BubbleMan in forum Windows Programming
    Replies: 12
    Last Post: 08-24-2001, 02:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21