Use the MoveWindow function Ex. MoveWindow(&myRect, TRUE);
RuiSantiago
Posts
-
Increase resizing border width.... -
How to Get LPDRAWITEMSTRUCT from CWnd pointer?How can i assign a value to the LPDRAWITEMSTRUCT struct parameters? I tried : void CMyButton::Activa(CWnd *pWnd, BOOL bEnable) { CRect rc; pDIS->itemAction = ODA_DRAWENTIRE; <-error pDIS->hwndItem = pWnd->GetSafeHwnd(); <-error pDIS->hDC = (HDC)pWnd->GetDC(); <-error pWnd->GetWindowRect(rc); pDIS->rcItem = rc; <-error CString sTexto; //desactiva a o botao e os seus tooltips pWnd->EnableWindow(bEnable); m_ToolTip.DelTool(pWnd, 0); //vai buscar ourtros dados do botao iCtrl=pWnd->GetDlgCtrlID(); pWnd->GetWindowText(sTexto); //passa o estado do botao para uma member variavel bDisabled=bEnable; DrawButton(iCtrl, pDIS, sTexto); } having BOOL bDisabled; int iCtrl; LPDRAWITEMSTRUCT pDIS; as member variables Thank you
-
Resources .rc questionI'm not sure about the maximum size of characters in the string table, but maybe you could use it for the purpose! Then you can load it into a CString like: CString rr; rr.LoadString(IDS_STRING); hope this helps
-
How to Get LPDRAWITEMSTRUCT from CWnd pointer?Hi! I'm using owner draw buttons, and i have the need of making them disabled in some situations, i have this function: void CMyButton::Activa(CWnd *pWnd, BOOL bEnable) { int iCtrl=0; CString sTexto; pWnd->EnableWindow(bEnable); m_ToolTip.DelTool(pWnd, 0); iCtrl=pWnd->GetDlgCtrlID(); pWnd->GetWindowText(sTexto); } This is called by the form class where the button is. With pWnd i would also like to call its LPDRAWITEMSTRUCT, so i can call void CMyButton::DrawButton(int nIDCtl, LPDRAWITEMSTRUCT pDI, CString sTexto) and redesing the button for that situation, i'm not sure if this is the best solution for the propose but its the only i know! Thank you for your time! rui
-
OnDrawItem questionHello everyone!! I'm using OnDrawItem in a Form to draw some objects. I would like to know how can i recall that function after pressing a button (since the button is owner draw, i would like the user to notice when he is pressing a button). What i really want is to get the LPDRAWITEMSTRUCT struct. How can i do this? Thank you for your time
-
Clear List BoxHi! The easier way to clear a listbox contents is to use the ResetContent function. If your control member variable that represents your ListBox is m_lsXXX then just write m_lsXXX.ResetContent(); I hope this helps
-
Font problemThank you Dominik for your advise, Well, the '==' operator dosen't work, because hFont is not a pointer. Is there a way to test if hFont was created? Now its Working fine, thank you very much
-
Font problemHello, I'm changing a form background color using OnEraseBkgnd(CDC* pDC) I'm also drawing texto and using a CFont for the propose. The problem is when OnEraseBkgnd(CDC* pDC) is called the second time, i'm using the font like: VERIFY(hFont.CreateFont(40, 15, 0, 0, FW_NORMAL,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial Bold")); pOldFont=pDC->SelectObject(&hFont); pDC->SelectObject(hFont); pDC->DrawText(sFormName, -1, CRect(15, 0, rc.Width(),80), DT_LEFT|DT_SINGLELINE|DT_VCENTER); pDC->SelectObject(&pOldFont); But, after it exits the function i get an error. What am I doing wrong? Thank you for your time
-
Drawing DoubtI'm working with vc.nte, i don't know if it makes a diference... That cast is part of a piece of code i got and it worked, i hope that is not the reason this doesn't work. And, honestly, i don't know how to deselect my font out of the device context. The main reason i'm trying to do this is because the forms layout isn't completly defined, so if later i had to make changes in all, it would be easier, and if i could spare from creating more objects in my forms it would be better, but maybe that is what i'm going to do... Thank you a lot for your time and dedication ;) rui
-
Drawing DoubtWell, i'm just Using OnDraw() The function is : void CLayout::OnDraw(CDC* pDC) { //cria os objectos CBrush brush(RGB_FUNDO); CBrush* pTempBrush = NULL; CBrush OrigBrush; CString sFormName="New Machines"; CFont hFont; CRect rc; try { //cria a fonte para as letras de identificação do form VERIFY(hFont.CreateFont(40, 15, 0, 0, FW_NORMAL,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial Bold")); //define a area total do ecran pWnd->GetClientRect(&rc); //seleciona o brush (cor) a usar pTempBrush = (CBrush*)pDC->SelectObject(brush); //guarda o brush original OrigBrush.FromHandle((HBRUSH)pTempBrush); //desenha o rectangulo a pintar com aquele brush pDC->Rectangle(0, 0, rc.Width() , rc.Height()); //defino a cor do texto pDC->SetTextColor(RGB_WHITE); //elimino o bkgrn do texto pDC->SetBkMode(TRANSPARENT); //associa-lhe a fonte criada pDC->SelectObject(hFont); pDC->DrawText(sFormName, -1, CRect(15, 0, rc.Width(),80), DT_LEFT|DT_SINGLELINE|DT_VCENTER); } catch(CResourceException* e) { e->ReportError(); e->Delete(); } pDC->SelectObject(&OrigBrush); } I used this function in a OnDraw override from CFormView in my other class and i never thought it would be so dificult to make a class just for the propose... X| I would appreciate very much if you could still hepl me with this, thanks a lot :-D
-
Drawing DoubtThank you dabs for the recommendation, I changed my code, it runs, in debug mode it passes without any problem by all code lines. Maybe the way i'm passing the pWnd pointer is incorrect, i'm doing like: CLayout::CLayout(CWnd* pWnd1) { pWnd=pWnd1; } pWnd is a member variable of CLayout My class is : class CLayout { public: CLayout(CWnd* pWnd1=NULL); ~CLayout(void); CWnd* pWnd; public: virtual void OnDraw(CDC* pDC); }; Should it be derived from CFormView also? I don't understand, it just don't draw, well, now rc is 0 for the four items...so it couldn't draw I'm suspicious about the pWnd that i pass from one class to another. What do you think? Thank you for your patience :)
-
Drawing DoubtThank you dabs, I changed my code, now in my CFormView derived class OnInitialUpdate() i did like: ClientDC dc( this ); CWnd* cWnd=dc.GetWindow(); CLayout ly(cWnd ); ly.OnDraw( &dc ); then, i CLayout CRect rc; cWnd->GetClientRect(&rc); GetClientRect((HWND)cWnd, &rc); cWnd->ScreenToClient(&rc); but rc is like : tagRECT: {top=32730 bottom=32730 left=32768 right=32768} well, i forced other values, and it didn't draw the same, but in debug mode, i follow the pointer and it seems ok. What can i be doing wrong? Thanks once more for your time
-
Drawing DoubtHi, I'm working on an application with many forms, i designed a layout for all the forms, but i wanted to build a class that had OnDraw(CDC* pDC) so i didn't have to override it from all my CFormView derived classes. I created a CLayout Class with OnDraw(CDC* pDC) function and now i would like to call it from other classes so i could draw and paint the forms. But, how can i get the pDC of this form? And i also need the hWnd pointer in my CLayout::OnDraw Function In my derived call i wrote: HWND* hWnd=NULL; hWnd=(HWND*)this->operator HWND(); CDC pDC=::GetDC(*hWnd); CLayout ly(hWnd); ly.OnDraw(&pDC); ...but GetDC function returns a HDC no CDC... This is my OnDraw Function... void CLayout::OnDraw(CDC* pDC) { //cria os objectos CBrush brush(RGB_FUNDO); CBrush* pTempBrush = NULL; CBrush OrigBrush; CString sFormName="New Machines"; CFont hFont; CRect rc; try { //cria a fonte para as letras de identificação do form VERIFY(hFont.CreateFont(40, 15, 0, 0, FW_NORMAL,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial Bold")); //define a area total do ecran GetClientRect(*hWnd,&rc); ScreenToClient(*hWnd,&rc); //seleciona o brush (cor) a usar pTempBrush = (CBrush*)pDC->SelectObject(brush); //guarda o brush original OrigBrush.FromHandle((HBRUSH)pTempBrush); //desenha o rectangulo a pintar com aquele brush pDC->Rectangle(0, 0, rc.Width() , rc.Height()); //defino a cor do texto pDC->SetTextColor(RGB_WHITE); //elimino o bkgrn do texto pDC->SetBkMode(TRANSPARENT); //associa-lhe a fonte criada pDC->SelectObject(hFont); pDC->DrawText(sFormName, -1, CRect(15, 0, rc.Width(),80), DT_LEFT|DT_SINGLELINE|DT_VCENTER); } catch(CResourceException* e) { e->ReportError(); e->Delete(); } pDC->SelectObject(&OrigBrush); } What am i doing wrong Thank you for your time rui
-
CListCtrl's rows colorsHi, My name is Rui, and i'm developing an MFC application with VC.NET. I would like to change, by code, the back color of a certain line or item. I read some articles on the subject, but i still can't, i found some solution very dificult... Thank you for your time Rui
-
FormView override doubtThanks again Papa! But i don't think i must use OnDraw, i just want to find a way of calling some code after OnActivateView is finished. Is that possivel?...I even thougth on using timers... Thanks
-
FormView override doubtI tried that, with and without GetParentFrame()->RecalcLayout(); And in none of those ways i got satisfactory results. I'm doing like : void CStocks::OnDraw(CDC* /*pDC*/) { CRect myRect; CSize mySize; GetClientRect(&myRect); if (myRect.bottom<=m_iLastY) { myRect.bottom+=500; MoveWindow(&myRect, FALSE); mySize=myRect.Size(); SetScrollSizes(MM_TEXT, mySize); //GetParentFrame()->RecalcLayout(); } } After OnActivateView is finished, i have the final value for m_iLastY, and then iwant to use it to resize, is there an alternative to OnDraw? Am i doing something wrong? Thank again
-
FormView override doubtWell, i'm a beginner and, I want to execute the following piece of code just after OnActivateView. I am not sure about OnDraw(). I tried placing the code in OnDraw() but I got a flickering screen. CRect myRect; CSize mySize; GetClientRect(&myRect); if (myRect.bottom<=y) //y is the vertical position of my last object { myRect.bottom+=200; MoveWindow(&myRect, TRUE); mySize=myRect.Size(); SetScrollSizes(MM_TEXT, mySize); GetParentFrame()->RecalcLayout(); } What am I doing wrong? Thanks for your trouble.
-
FormView override doubtHello! I'm overriding OnActivateView function in my CFormView derived class, and it is in that function that i'm creating and displaying some objects, the number of objects depends on a database query. In order to resize my form, i must have its CRect parameters. Inside OnActivateView i do : GetClientRect(&myRect);, but all the size parameters (left, top, right, bottom) are equal to 0. Maybe i'm wrong but i understand that these values should only be available when OnActivateView is finished. My question: Is there an onverride for CFormView that is called after OnActivateView and where CRect parameters are available? Thank you in advance
-
Form Scrolling ProblemSure it helped, i got it working :-D Thank you very much Lucy, i hope i can help you when you need it
-
Form Scrolling ProblemThank you Lucy, i tried your suggestion, i did like: CRect myRect; CSize mySiz:omg:e; this->GetClientRect(&myRect); mySize=myRect.Size(); for (int i=0;i<100;i++) { caramba[i] = new CStatic; g.Format("%d", i); caramba[i]->Create(g, WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER, CRect(10, i*10, 120, i*10+50), this); myRect.bottom+=20; } MoveWindow(myRect.left, myRect.top, myRect.right, myRect.bottom); this->GetParentFrame()->RecalcLayout(); this->SetScrollSizes(MM_TEXT, mySize); this->ShowScrollBar(SB_VERT, TRUE); this->SetScaleToFitSize(mySize); Even using SetScrollSizes and ShowScroll after RecalcLayout, it apears for half a second or something, and then disapears again. I tried SetScaleToFitSize and it did not improve Why does this appends? Thank you in advance