Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

getting text out to screen without using OnPaint() or OnDraw()

MFCGuyMFCGuy Member Posts: 3
Hello,

I want to create a muliti versitle program for different applications. I don't want my functions that send text out to screen to use OnDraw or OnPaint, because these functions will have member variables like Staves(int i) and etc. Reason being due to the fact I am using menu dialoog selections that these text out functions will use in their creation. I can do this using:

CWnd* pWnd=AfxGetMainWnd();
CDC* pDC=pWnd->GetDC();
....
pWnd->ReleaseDC(pDC);

but the problem is that if the window is resized or scroll the text is erased, due to the OnDraw() function being called within the MFC document/view application I'm using.

Can someone suggest a way of getting text out using MFC document/view without using OnDraw() or OnPaint()?

Thankyou for your attention!

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    [b][red]This message was edited by stober at 2005-6-15 11:35:57[/red][/b][hr]
    : Hello,
    :
    : I want to create a muliti versitle program for different applications. I don't want my functions that send text out to screen to use OnDraw or OnPaint, because these functions will have member variables like Staves(int i) and etc. Reason being due to the fact I am using menu dialoog selections that these text out functions will use in their creation. I can do this using:
    :
    : CWnd* pWnd=AfxGetMainWnd();
    : CDC* pDC=pWnd->GetDC();
    : ....
    : pWnd->ReleaseDC(pDC);
    :
    : but the problem is that if the window is resized or scroll the text is erased, due to the OnDraw() function being called within the MFC document/view application I'm using.
    :
    : Can someone suggest a way of getting text out using MFC document/view without using OnDraw() or OnPaint()?
    :
    : Thankyou for your attention!
    :
    :

    you can do the drawing in any function you want and at any time. But I believe only OnDraw() is called by MFC when the screen must be repainted, such as when it is uncovered by another window. If you don't like how OnDraw() behaves, then just remove all the code from that function and do your own thing elsewhere.







  • MFCGuyMFCGuy Member Posts: 3
    : [b][red]This message was edited by stober at 2005-6-15 11:35:57[/red][/b][hr]
    : : Hello,
    : :
    : : I want to create a muliti versitle program for different applications. I don't want my functions that send text out to screen to use OnDraw or OnPaint, because these functions will have member variables like Staves(int i) and etc. Reason being due to the fact I am using menu dialoog selections that these text out functions will use in their creation. I can do this using:
    : :
    : : CWnd* pWnd=AfxGetMainWnd();
    : : CDC* pDC=pWnd->GetDC();
    : : ....
    : : pWnd->ReleaseDC(pDC);
    : :
    : : but the problem is that if the window is resized or scroll the text is erased, due to the OnDraw() function being called within the MFC document/view application I'm using.
    : :
    : : Can someone suggest a way of getting text out using MFC document/view without using OnDraw() or OnPaint()?
    : :
    : : Thankyou for your attention!
    : :
    : :
    :
    : you can do the drawing in any function you want and at any time. But I believe only OnDraw() is called by MFC when the screen must be repainted, such as when it is uncovered by another window. If you don't like how OnDraw() behaves, then just remove all the code from that function and do your own thing elsewhere.
    :
    :
    :
    :
    :
    :
    :
    :
    That's why I'm posting this question. I have done the textout in my own function outside OnDraw(). But if you resize or scroll the screen the text is lost. Thats where I need help.
  • PalmpjePalmpje Member Posts: 51
    : : [b][red]This message was edited by stober at 2005-6-15 11:35:57[/red][/b][hr]
    : : : Hello,
    : : :
    : : : I want to create a muliti versitle program for different applications. I don't want my functions that send text out to screen to use OnDraw or OnPaint, because these functions will have member variables like Staves(int i) and etc. Reason being due to the fact I am using menu dialoog selections that these text out functions will use in their creation. I can do this using:
    : : :
    : : : CWnd* pWnd=AfxGetMainWnd();
    : : : CDC* pDC=pWnd->GetDC();
    : : : ....
    : : : pWnd->ReleaseDC(pDC);
    : : :
    : : : but the problem is that if the window is resized or scroll the text is erased, due to the OnDraw() function being called within the MFC document/view application I'm using.
    : : :
    : : : Can someone suggest a way of getting text out using MFC document/view without using OnDraw() or OnPaint()?
    : : :
    : : : Thankyou for your attention!
    : : :
    : : :
    : :
    : : you can do the drawing in any function you want and at any time. But I believe only OnDraw() is called by MFC when the screen must be repainted, such as when it is uncovered by another window. If you don't like how OnDraw() behaves, then just remove all the code from that function and do your own thing elsewhere.
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : That's why I'm posting this question. I have done the textout in my own function outside OnDraw(). But if you resize or scroll the screen the text is lost. Thats where I need help.
    :

    So, why not just call your drawing function from OnDraw?
  • MFCGuyMFCGuy Member Posts: 3
    : : : [b][red]This message was edited by stober at 2005-6-15 11:35:57[/red][/b][hr]
    : : : : Hello,
    : : : :
    : : : : I want to create a muliti versitle program for different applications. I don't want my functions that send text out to screen to use OnDraw or OnPaint, because these functions will have member variables like Staves(int i) and etc. Reason being due to the fact I am using menu dialoog selections that these text out functions will use in their creation. I can do this using:
    : : : :
    : : : : CWnd* pWnd=AfxGetMainWnd();
    : : : : CDC* pDC=pWnd->GetDC();
    : : : : ....
    : : : : pWnd->ReleaseDC(pDC);
    : : : :
    : : : : but the problem is that if the window is resized or scroll the text is erased, due to the OnDraw() function being called within the MFC document/view application I'm using.
    : : : :
    : : : : Can someone suggest a way of getting text out using MFC document/view without using OnDraw() or OnPaint()?
    : : : :
    : : : : Thankyou for your attention!
    : : : :
    : : : :
    : : :
    : : : you can do the drawing in any function you want and at any time. But I believe only OnDraw() is called by MFC when the screen must be repainted, such as when it is uncovered by another window. If you don't like how OnDraw() behaves, then just remove all the code from that function and do your own thing elsewhere.
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : That's why I'm posting this question. I have done the textout in my own function outside OnDraw(). But if you resize or scroll the screen the text is lost. Thats where I need help.
    : :
    :
    : So, why not just call your drawing function from OnDraw?
    :
    Because I have the program set up for a user to select from 7 choices under a menu option. Within that selection a number is initalized and sent to my function where the text out is located. I couldn't find a way to send that variable to OnDraw().

  • stoberstober Member Posts: 9,765 ✭✭✭
    : :
    : Because I have the program set up for a user to select from 7 choices under a menu option. Within that selection a number is initalized and sent to my function where the text out is located. I couldn't find a way to send that variable to OnDraw().
    :
    :

    Make the menu choice a member of the same class in which OnDraw() is located. OnDraw() can then pass it on to your drawing function.
  • FDracheFDrache Member Posts: 64
    There is always a way to give a number 1..7 to your function. If a calling parameter does not fit, use a variable. Set that variable with the menue item(s).
    : Because I have the program set up for a user to select from 7 choices under a menu option. Within that selection a number is initalized and sent to my function where the text out is located. I couldn't find a way to send that variable to OnDraw().
    :




  • justmeherejustmehere Member Posts: 4
    I realize that this thread is quite old but I thought I would share my experience with others who stumble onto this thread looking for a solution. I found out for my needs that CEditView and CRichEdit did the trick. Another possibility which I think someone has also mentioned is the CListView.

    Cheers
Sign In or Register to comment.