|
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!"
|
|
|
|
|
Taken from MSDN:
A pointer to a variable that receives the thread identifier. If this parameter is NULL, the thread identifier is not returned.
It means that it an "outgoing" parameter: you pass the address of a DWORD in which the thread Id will be stored. So, there's no problem in passing an uninitialized DWORD because it won't be read by the CreateThread function.
|
|
|
|
|
Hi,
Thanks for the help!!
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Since when is saying thanks worthy of a '1' vote?
|
|
|
|
|
Do note that this parameter is useless for all practical purposes.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I occasionally use it in logging data if I'm tracking what various threads are doing. It's a little easier on the eyes than using the thread handle.
Judy
|
|
|
|
|
Hello,
I have a problem with opening a view, while opening a document (MDI).
What i do is I have a configuration file and when i read it, i can open a debug view (richtextview) and see the details about the configuration. I can import as many as configuration files i want. I can also open a document attached with a configuration file, but cannot open the debug view .
BOOL Test::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
CMainFrame* mainWnd = (CMainFrame*)AfxGetMainWnd();
mainWnd->OnNewwindowDebugwindow();
Log().inform("Hello !",getDebugWindow());
}
In above code, the mainframe creates a debug window, and getDebugWindow() just finds the debug view if there is any, and in the OpenDocument, it always returns NULL. the question is how i can create a view while opening a document?
CDebugWindow* Test::getDebugWindow()
{
if(debugWindow==0)
{
POSITION pos = GetFirstViewPosition();
CView* pView=0;
bool found=false;
while (pos != NULL)
{
pView = GetNextView(pos);
if(pView->IsKindOf(RUNTIME_CLASS(CDebugWindow)))
{
found=true;
break;
}
}
if(found)
{
debugWindow = (CDebugWindow*) pView;
return debugWindow;
}
else
return 0;
}
else
return debugWindow;
}
Thanks in advance.
Bekir.
|
|
|
|
|
Hello, I have a weird problem regarding the deleting of a folder.
I'm trying to delete a folder using this code
TCHAR exeDirectory[MAX_PATH];
GetCurrentDirectory(sizeof(exeDirecotry) - 1, exeDirectory);
CString szStoreFolder;
szStoreFolder.Format(_T("%s\\td10"),exeDirectory);
......
SHFILEOPSTRUCT op;
op.pFrom = szFolderName;
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
op.fAnyOperationsAborted = false;
op.hNameMappings = NULL;
int er= SHFileOperation(&op);
_tprintf(_T("Eroare %d "),er);
The problem is that it doesn't work every time.
It depends on the exeDirectory name and on the folder name (the folder that I'm trying to delete)
For instance if the exeDirectory is TEST and the folder name is Td10 it doesn't work. If the exeDirectory is ZIP_OPTION and the folder name TD10 it works. If the exe folder is TEST and the folder name is TemporaryData it works but now for the ZIP_OPTION folder it dosn't work.
I made a debug and the szFolder contains the correct path.
I've got the error 1026.
I tried to take the path with CFileFinder but still the same problem appears. I tried also to take the short folder name but it the same. I do not know what to do.
Any help or advice would be appreciate
Tnx
|
|
|
|
|
Why are you using GetCurrentDirectory()?
I don't know the rest of your code but there is a chance that the current directory changes after a recursive deletion with SHFileOperation or elsewhere in your code.
Also, you are mentioning 3 different variables for the path: "szStoreFolder", "szFolder" and "szFolderName". Very confusing.
|
|
|
|
|
problem solved
You should use the relative name to the current folder and the short name of the folder DOES NOT WORK WITH LONG FOLDER NAME.
|
|
|
|