Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,443 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,219 people online right now. Registration is fast and FREE... Join Now!




TextOut() disppaers when another window covers it?

 
Reply to this topicStart new topic

TextOut() disppaers when another window covers it?

chronoTrigger
30 Oct, 2007 - 02:11 PM
Post #1

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 43


My Contributions
how can I avoid my lines of texts to not disappear when I drag another window over my textout window? Under WM_PAINT in WndProc I use TextOut() to draw out the text, but when it's covered up by another window, the number of texts just disappears only the last line of text showing up but the rest is erased, so how can I prevent that? I use InvalidateRect(), but still don't work.
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: TextOut() Disppaers When Another Window Covers It?
30 Oct, 2007 - 03:10 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,654



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Usually this is a sign of not firing a repaint when you are suppose to. However we can't find that out without any code displayed. Perhaps you can help us out and provide some and then maybe someone will go "AH HA! There is the problem!" and all will be right with the world.

Then you will be able to go on and make billions of dollars and you can forget about us guys at DIC. hehe smile.gif
User is online!Profile CardPM
+Quote Post

chronoTrigger
RE: TextOut() Disppaers When Another Window Covers It?
30 Oct, 2007 - 04:21 PM
Post #3

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 43


My Contributions
QUOTE(Martyr2 @ 30 Oct, 2007 - 04:10 PM) *

Usually this is a sign of not firing a repaint when you are suppose to. However we can't find that out without any code displayed. Perhaps you can help us out and provide some and then maybe someone will go "AH HA! There is the problem!" and all will be right with the world.

Then you will be able to go on and make billions of dollars and you can forget about us guys at DIC. hehe smile.gif

Billion of dollar hahaha? that's alot of money, but nah I don't want that much; just enough for the living and not owning any debt that's all good for me, also who knows maybe down the road if I become expert like you, I may join you guys the super star coders at DIC.

CODE

int textPosition = 350; //this is the position where thetext should be at
const int maxDisplayLine = 10; //limit how many lines availabe to display the text
int currentDisplayLinePosition = 0; //this keeps track the current position of the displaying text
int textLength = 0;
LPSTR id = NULL;

void zoomTextDescription(LPSTR descriptionID, int length, int posY)
{
        
    HWND menuWindow = FindWindow(NULL, TEXT("My Window"));
                    
    if(currentDisplayLinePosition < maxDisplayLine)
    {
        currentDisplayLinePosition +=1;
        textPosition = posY;
        textLength = length;
        id = descriptionID;
        InvalidateRect(menuWindow, NULL, FALSE);
    }
    else    //even though the condition is fail, but there is one text description
    {        //left of that fail condition need to display

        currentDisplayLinePosition = 0;
        textPosition = 300;
        textLength = length;
        id = descriptionID;
        InvalidateRect(menuWindow, NULL, FALSE);
    }
}


LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {

    case WM_COMMAND:

        switch(LOWORD(wParam))
        {

        case ID_MENU_ZOOMme:
            {
                DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_zoomCommand), hwnd, AboutDlgProc1);
            }
            break;

        case WM_PAINT:
        {

            HDC hdc = GetDC(hwnd);
            TextOut(hdc, 5, textPosition, (LPCWSTR)id, textLength);
            ReleaseDC(hwnd, hdc);

        }
        break;

    case WM_DESTROY:
        {
            PostQuitMessage(0);
        }
        break;
    }

    return DefWindowProc(hwnd, message, wParam, lParam);
}



BOOL CALLBACK AboutDlgProc1(HWND dlg, UINT message, WPARAM wParam, LPARAM lParam)
{

    switch(message)
    {
    case WM_COMMAND:
        switch(LOWORD(wParam))
        {

        case IDC_magnifyOn:
            {
                    zoomTextDescription((LPSTR)TEXT("Magnify On"), (int)strlen("Magnify On"), textPosition +=18);

            }
            break;  
        case SC_CLOSE:
        case WM_DESTROY:
        //case WM_QUIT:
        case WM_CLOSE:
            {

                EndDialog(dlg, 0);
                PostQuitMessage(0);
                return TRUE;    

            }
            break;

        }//end of COMMAND message switch case

    }//end of message switch case


    return FALSE;
}


basically my code above, have a menu and under the menu it has submenu where it will open a dialog box with one button to click on. Whenever that button is clicked on, it will call zoomTextDescription() to update the global variables so it can be drawn inside the WndProc(). Each text will display line by line with the starting position at 350, the space between each line is 18. So if I click on the button for many times then i drag another window over those display texts, they will get erased except the last line is showing.

This post has been edited by chronoTrigger: 30 Oct, 2007 - 04:34 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 12:40PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month