|
I hate mondays .... yeah, monday's posts on tuesday mornings....
This signature was proudly tested on animals.
|
|
|
|
|
Try @
www.rentacoder.com
www.getfreelancer.com
www.getacoder.com
etc... If still unable then directly contact me...
Good luck...
Jagdish Bhimbha
S/W Engineer
|
|
|
|
|
Hello
I've searched google and MSDN but cannot search the forums here yet as it keeps timing out. I've managed to improve my problem butnot completely resolve it.
My application is divided into 3 panes (left, right and bottom). In one of them is a window derived from CSizingTabCtrlBar. This has 3 tab views assigned to it.
One of these tab views uses a CTreeCtrlDnD object and so looks like an explorer window.
The problem was two fold:
1) If I opened a modal dialog that happened to obscure part of this window and then closed it again, the part of the underlying window that was hidden was not redrawn. It would be redrawn if I toggled the view however.
2) If I minimize / maximize the application then the explorer view is greyed out. This occurs no matter what view (of the 3 tabbed views) is active at the time that the application is minimized. I.e. so even if the the "explorer" view is not active and hidden under one of the other tabbed views, if I minimize and maximize the application then select the "exploer" view it is greyed out. Again, if I cycle the views using the tabs it is redrawn correctly.(Also, I sometimes need to cycle views twice).
Through using the debugger I know that the relevant OnDraw and OnPaint messages are being called and so I guess the WM_PAINT message is being sent as expected. (I tried using Spy++ to confrim message is being sent but it keeps crashing)
I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:
void CWorkspaceWindowTab2View::OnDraw(CDC *pDC)
{
this->UpdateWindow();
CView::OnDraw(pDC);
}
However, even though the program is entering this OnDraw method when I minimize/maximize the application the explorer view (CWorkspaceWindowTab2View) is not being redrawn.
Any ideas?
Thanks in advance
Rich
modified on Tuesday, June 10, 2008 6:36 AM
|
|
|
|
|
kildareflare wrote: the part of the underlying window that was hidden was not redrawn
Maybe you could send a Redraw message to that view when closing your dialog ?
kildareflare wrote: the explorer view is greyed out
Do you mean "disabled", or simply filled with grey color ?
|
|
|
|
|
Hello, I mean that the view is filled with grey colour. Occasionally, one the root item of the tree will also be displayed, with everything else grey.
As it happens there is no longer a problem when closing the dialog. that was fixed when i overode the base class OnDraw function.
The problem that remains is when the application is minimized and then maximized again....
|
|
|
|
|
It looks like the drawing stuff is not done in the OnPaint method but somewhere else in the code. It means that the redrawing is not handled properly.
Did you write the code yourself ?
|
|
|
|
|
Hi Cedric
I wrote some of the code myself, some i inherited and the rest is standard MFC stuff.
The application only contains dialogs and buttons etc there are no user defined images etc that required customised drawing methods. With the exception of the problem listed the default base class methods (CView) handle the redrawing of all items correctly.
while you may be correct that OnPaint is not doing the drawing whatever is doing it is part of the MFC and so one would imagine that would work OK, right?
I initially thought the problem was that for some reason the window was not receiving a WM_PAINT message. However since the program allways breaks at the OnDraw methodit must be....
I have completed some more testing and have the following to add...
When the app is first opened this problem does not occur.
If i then do anything that causes the explorer view ot refresh (Correctly) add an item to the explorer view for example. The problem is now present until the application is restarted...
|
|
|
|
|
Take help of
UpdateData(FALSE);
I think thats only missing in ur code...
Have good luck...!
Jagdish Bhimbha
S/W Engineer
|
|
|
|
|
kildareflare wrote: I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:
This shouldn't fix anything. OnDraw() is called for every WM_PAINT message
so calling UpdateWindow() to force a WM_PAINT message from the WM_PAINT
message handler is just wrong.
If you are using both WM_PAINT handlers and OnDraw() in your CView-derived classes,
then make sure you're not doing recursive stuff like this.
It's much simpler to use just the OnDraw() method for your painting.
If you must use your own WM_PAINT handler, then you can eliminate the OnDraw()
virtual call if you need to.
See the source code for CView::OnPaint() for details.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello All
I've found the solution to the problem, thoug not sure exactly why.
Since the "explorer" view allways drew itself correctly when the application is first started and also when resizing the view I guessed that one difference is that the problem occurs when trying to update the view while it is not in focus - i.e. minimized.
Figuring that there must be something different in the two scenarios I checked the InitialiseTreeCtrl method. The only extra code completed here that was not called when the window was minimized was a call to destroy and then recreate the control.
I found that I needed to call the above function prior to calling setFocus() and UpdateWindow(). This appears to resolve the problem.
I have moved the calls to SetFocus and UpdateWindow from the overriden OnDraw method to my mainFrames Move method, since this is called when the window is minimized/maximized.
So the code required to fix this is below:
workspacewindow is derived from CSizingTabCtrlBar
After getting a pointer to the view on which the explorer window lies I have to:
1) Initialize the tree (destroy it and creat again, resize as appropriate and assign image list)
2) Update the tree (insert items from list, expand and ensure visibile)
3) Invalidate ctrl
4) Give the view and so control focus
5) Update the window
void CMainFrame::OnMove(int x, int y)
{
CWorkspaceWindowTab2View* pWorkspaceTab2View = (CWorkspaceWindowTab2View*)((CMainFrame*)theApp.m_pMainWnd)->m_pWorkspaceWindow->GetView(EXPLORER_VIEW);
pWorkspaceTab2View->InitializeLoopBrowserTree();
pWorkspaceTab2View->UpdateLoopBrowserTree();
pWorkspaceTab2View->GetDlgItem(IDC_LOOPS_TREE)->Invalidate(TRUE);
pWorkspaceTab2View->SetFocus();
pWorkspaceTab2View->UpdateWindow();
}
Although, I have just noticed that occasionly when changing views using the tabcontrol this view is not updated. I can "fix" this also by placing a call to the InitialiseTreeCtrl method in the CSizingTabCtrlBar::SetActiveView method, however this of course breaks a few rules...any other suggetions...?
Thanks
Rich
modified on Wednesday, June 11, 2008 8:29 AM
|
|
|
|
|
Hi
Custom Draw, Owner Draw, Custom Control, Owner Draw Control...
Overriding DrawItem() Method, Overriding OnPaint() Method, OnCustomDraw()
Method, WM_CTLCOLOR Handler, adding custom control which is in toolbox and
"Custom Control DLL"...
I started to search control development in MFC to learn how to write
(stylish)controls but it seems that it will be difficult and confused...
I have basic 2 questions, if you help me to find answers i will be very glad.
1-) In Terminology, are "custom control" and "owner draw control" same
things? If not, i understand that custom control means that writing "custom
control dll" and overriding OnPaint() method and this control will be
reusable in other projects. But owner draw control means changing controls
color for that solution and we only override DrawItem() method. Am i right?
2-) As seen and i am correct, there are many ways to draw a control with
different style and colors. If i want to make a button with gradient color
and want to add it in Toolbox to use in different projects and there will be
2 color options that developer will adjust for drawing button in properties
window when add it to form and select it. Which way must i choose? What must
be the roadmap?
Thanks..
|
|
|
|
|
1) Good question. To my understanding, custom controls usually have customized functionalities, which are not necessarily another layout or skinning. Owner drawn is when you change how the things look like, but not necessarily change the functionality. But you can mix the two of them. I think that custom controls are not necessarily owner drawn, while owner drawn are usually customs.
2) You can use both ways. Search for article about Buttons here on CP, and make your choice.
|
|
|
|
|
owner drawn means that the underlying control provides a mechanism to allow you to draw display elements.
custom controls are where you either write a control from scratch or override functionality in a base control, usually through preclassing, subclassing or reflection. (If using MFC, you can just override some virtual functions, several of which do one of the previous things.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
In MSDN:
NM_CUSTOMDRAW: This message is sent by some common controls to notify their parent windows about drawing operations
WM_DRAWITEM: This message is sent to the owner window of an owner-drawn button or menu when a visual aspect of the button or menu has changed.
Is there a difference between override CustomDraw method and DrawItem method?
|
|
|
|
|
NM_CUSTOMDRAW is used by the common controls library. WM_DRAWITEM is for basic windows controls. They are logically the same thing.
DrawItem() handles WM_DRAWITEM messages. There is no CustomDraw() method for any MFC classes. If such a method exists, you, or a third party, added it. A guess would be that it handled NM_CUSTOMDRAW messages, but if not documented, you'd have to examine the actual parameters and even the message map.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
When I compile the project, there are some linking warnings like:
"libcmt.lib(mktime64.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib\libcmt.lib' or at 'c:\Documents and Settings\member\desktop\MyProject\Release\Source 0.31.84\Release\libcmt.pdb'; linking object as if no debug info"
Is this warning not a problem or should I fix this?
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Libcmt is a Microsoft library for multi-threading. .PDB files contain debugging information. It looks like the debugging information for libcmt can't be found by the linker.
The first thing to try is to search your hard disk for libcmt.pdb. If you find it, add its folder to the paths searched by the linker (or copy it to a place your linker can find it).
If you're not using multi-threading, turn it off so the linker won't look for this file.
|
|
|
|
|
Hi,
Thanks for the great help!!
I entered the path in Linker --> Additional Library Directories, and the warnings went.
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Hi,
I keep reading articles that says I can use this code to navigate activex webbrowser on a dialog
BOOL Ctry7Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
/******************************************/
COleVariant varEmpty;
m_wb.Navigate2("http://www.google.com",
&varEmpty,
&varEmpty,
&varEmpty,
&varEmpty);
/******************************************/
return TRUE;
}
but everytime run the code, I woul get this error:
error C2664: 'CWebbrowser2::Navigate2' : cannot convert parameter 1 from 'const char [34]' to 'VARIANT *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
can someone help me out here ??? Thanks
|
|
|
|
|
limesp wrote: COleVariant varEmpty;
m_wb.Navigate2("http://www.google.com",
&varEmpty,
&varEmpty,
&varEmpty,
&varEmpty);
change to
COleVariant varEmpty;
COleVariant varUrl(_T("http://www.google.com"));
m_wb.Navigate2(&varUrl,
&varEmpty,
&varEmpty,
&varEmpty,
&varEmpty);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi all,
How can I convert CComPtr<istream> stream into ostream.
Can anyone of you give me a clue.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You're joking, Mr.CodingLover.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I'm completely wried with that sir.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
If you can tell me how to find the length of the IStream member?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
What is the use of CreateThread() function's last parameter "LPDWORD lpThreadId
".
Can we give some user defined value to this parameter?
In most of the programs some variable of type DWORD is declared and passed without initialization, is it no problem?
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|