|
Does anyone know a TreeCtrl that will display and allow you to run files (via double click), that will integrate into a MFC dialog (Modeless).
I did find CTreeFileCtrl in this site but could not get it into my dialog, it seems that it works for SDI applications and could not figure out how to integrate it.
I have found a few Tree controls but again all seem to be for MDI or SDI applications.
grahamfff
|
|
|
|
|
Grahamfff wrote:
I did find CTreeFileCtrl in this site but could not get it into my dialog, it seems that it works for SDI applications and could not figure out how to integrate it.
From the article[^]:
To use CTreeFileCtrl, include FileTreeCtrl.cpp / .h in your project (in addition to SortedArray.h) and #include "FileTreeCtrl.h" in the module you want to instantiate it in. You can use the usual MFC ways of hooking up the class. If you are using the class in a dialog resource, then you can use the DDX function provided or call the CWnd::SubclassWindow() function directly. You can also create the control dynamically by calling its parent classes CTreeCtrl::Create() method.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I am struggling with CPropertySheet / CPropertyPage to create a tabbed dialog box.
After creating a project, I Project/Add Component / VisualC++ Component / PropertySheet. Then, I selected a PropertySheet (instead of Wizard) with 3 tabs. The tabs showed up in the project as CMyPropertyPage1, 2, 3.
The CPropertyPage1 (2,3) is :: public CPropertyPage (subclass)
If I look at the header file CPropertyPage1.h, I see soemthing like:
// Dialog Data
//{{AFX_DATA(CMyPropertyPage1)
enum { IDD = IDD_PROPPAGE1 };
// NOTE - ClassWizard will add data members here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_DATA
Now, if I add some controls on any page, and double click on it for the handler code, Visual C++ asks me to create new class. Then, a new class is created based on CDialog. Assume its name is CMyPage1
CMyPage1 is :: public CDialog, and is also bound on the same dialog template:
// Dialog Data
//{{AFX_DATA(CPage1)
enum { IDD = IDD_PROPPAGE1 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
So, my question is:
Both CPropertyPage1 and CMyPage1 are refering to the same dialog template (IDD_PROPPAGE1). MyPropertySheet adds the CPropertyPage-typed variables in its constructor. CMyPage processes the handler code.
What is the relationship between CMyPage1 and CPropertyPage1 ? It seems to me that they are 2 parts of each tab. Why the hell do we need to have 2 separate classes that refer to the same thing ?
Thanks a lot for enlightening me.
|
|
|
|
|
hongheo76 wrote:
Now, if I add some controls on any page, and double click on it for the handler code, Visual C++ asks me to create new class. Then, a new class is created based on CDialog. Assume its name is CMyPage1
The class wizard should have given you the option of using an existing class. Take that option and select the correct CPropertyPage* class. You should have only one class per page, not two.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I have a dialog-based MFC application within which I need to do some serial I/O. Basically, I need to wait for a certain character to come in on the serial port. I'm successfully creating a file for the port in overlapped mode and starting ReadFile with a valid overlapped structure and event handler. Also, I'm using WaitForSingleObject() with a short timeout to check whether the event has been set or I've timed out.
What I want to do is cause my dialog to perform message handling (specifically redrawing) whenever WaitForSingleObject times out. That way the user will see a properly repainting display while we're waiting for the serial characters instead of what looks like a hung application. Any suggestions would be greatly appreciated.
Best Regards,
pHaze426
|
|
|
|
|
Put the serial port stuff in a separate thread and the GUI will remain responsive.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I could do that, but I'd still have to have the function launching the thread wait until the serial read completed before continuing with its tasks. Otherwise, I'd have to hook a callback function or something to handle a state machine that's called after each read. I just wondered if there was any other option as far as a function I could call to do processing while I'm waiting.
Best Regards,
Phaze426
|
|
|
|
|
pHaze426 wrote:
I could do that, but I'd still have to have the function launching the thread wait until the serial read completed before continuing with its tasks.
Nothing wrong with that (except for the "wait" part). Once the secondary thread has completed, it would post a message to the primary thread indicating it is done. At that point, the primary thread could do what it needed with the serial port data. No waiting is necessary. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
pHaze426 wrote:
I'm using WaitForSingleObject() with a short timeout to check whether the event has been set or I've timed out.
How are you doing that continuously without multiple threads and without blocking the UI thread? In a mesasge loop?
pHaze426 wrote:
What I want to do is cause my dialog to perform message handling (specifically redrawing) whenever WaitForSingleObject times out
Then use SendMessage() or PostMessage()
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I guess I am using threads in a roundabout sort of way. When I call CreateFile to open the serial port, I specify the OVERLAPPED I/O flag. Then, when I call ReadFile() I pass it an overlapped structure with an event handle. When it's done, it sets that event handle. (I guess this means that internally, Windows is spawning another thread for ReadFile). Anyhow. WaitForSingleObject just waits until the event handle is set, or its own timeout has expired. So... if I give the call to ReadFile a timeout of 10 seconds and the call to WaitForSingleObject a timeout of 100ms, I will get a chance to do something every 100ms until the serial I/O completes, or readfile times out after 10s.
Along the SendMessage lines, I've used:
this->SendMessage(WM_PAINT, 0, 0); from within this wait loop to no avail. Is there another message I should be sending?
|
|
|
|
|
Well if you don't need to send any data the just call CWnd::Invalidate() that will cause a Paint to occur.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Just for everyone's reference, I figured out a way to do this (granted, this way isn't all that clean and is probably more of a 16-bit windows style of doing things, but it works). Rather than using WaitForSingleObject to wait for the I/O to complete, I stuck in this:
while (MsgWaitForMultipleObjects(1,
&ol.hEvent,
FALSE,
10,
QS_ALLINPUT) !=
WAIT_OBJECT_0) {
while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE)) {
DispatchMessage ( &msg);
}
}
So... I just keep dispatching all the messages I received until the serial even becomes signalled. This seems to work well.
|
|
|
|
|
Ok, I have a CArray container like so:
<br />
CArray <myObject, myObject> objectList;<br />
and I declared a dynamic array in a separate class like so:
<br />
class SelectionBox<br />
{<br />
public:<br />
void AddContent(myObject *);
<br />
protected:<br />
myObject *content;
unsigned long numContents;
}<br />
So now I built my AddContent() function like this:
<br />
void SelectionBox::AddContent(myObject *c)<br />
{<br />
unsigned long counter;<br />
myObject *tempObject;<br />
tempObject = new myObject[numContents];<br />
<br />
tempObject = content;<br />
<br />
content = new myObject[numContents + 1];<br />
<br />
for(counter = 0; counter < numContents; counter++)<br />
{<br />
content[counter] = tempObject[counter];<br />
}<br />
<br />
content[numContents] = c;<br />
<br />
<br />
numContents++;<br />
delete [] tempObject;<br />
} <br />
Finally, in another part of the program, I shoot the address of one of the objects stored in the CArray to the AddContent function.
At first the function appeared to be working.. That is until I later tried to manipulate the original objects in the CArray by manipulating what I thought was the pointer to them in my SelectionBox class. Then I found out that I had copies of data stored and not a pointer to the CArray data. I can't for the life of me figure out how to declare the function and pass the data so that I can store an array of pointers/addresses to the data in the CArray container. Can someone show me an example, or maybe a link to a relevant tutorial?
|
|
|
|
|
|
That worked perfectly!!!! Thanks Pete.. I didn't even know that container existed, .. which will help a quite a few more problems I've been facing. Thanks Again
|
|
|
|
|
Hello,
I am writing a program that needs to do diffrent stuff depending on which OS it's running.
How can I do this?
Can I do it without GetVersionEx?
Can I do it with #if(WINVER >= #)? If so what values are for which OS?
Thanks.
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
KingKruncher wrote:
Can I do it without GetVersionEx?
Why would you want to?
KingKruncher wrote:
Can I do it with #if(WINVER >= #)? If so what values are for which OS?
See here for values.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
KingKruncher wrote:
Can I do it with #if(WINVER >= #)?
No, that is a compile time directive not a runtime evaluation.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
You'll eventually need to compile an exe for each version if you'll use #if(WINVER >= # method
It wont be the same exe
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
here you can use my code for this
//structure
struct NmpWindowVersion
{
public:
CString WindowName;//name of windows
int Plateform;//0 stand for single user and 1 stand for multi user
CString WindowsVersion;// contain the iformation abbt service pack etc
CString BuildNumber;
};
////function
int MeCheckVersionInfo(NmpWindowVersion &StructVar)
{
OSVERSIONINFO info;
info.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&info);
int nMajor,nMinor;
CString BuildStr;
//getting Verion nme
switch (info.dwMajorVersion)
{
case 3: StructVar.WindowName="Windows NT 3.51";
nMajor=3;
nMinor=51;
break;
case 4: switch(info.dwMinorVersion)
{
case 0:
if(info.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)
StructVar.WindowName="Windows 95";
else
StructVar.WindowName="Windows NT 4.0";
nMajor=4;
nMinor=0;
break;
case 10: StructVar.WindowName="Windows 98 ";
nMajor=4;
nMinor=10;
break;
case 90: StructVar.WindowName="Windows Me ";
nMajor=4;
nMinor=90;
break;
}
break;
case 5: switch(info.dwMinorVersion)
{
case 0: StructVar.WindowName="Windows 2000";
nMajor=5;
nMinor=0;
break;
case 1: StructVar.WindowName="Windows XP";
nMajor=5;
nMinor=1;
break;
case 2: StructVar.WindowName="Windows Server 2003 family 2";
nMajor=5;
nMinor=2;
break;
}
break;
}
////getting Plateform ID
switch(info.dwPlatformId)
{
case VER_PLATFORM_WIN32_WINDOWS:StructVar.Plateform=0; break;
case VER_PLATFORM_WIN32_NT :StructVar.Plateform=1; break;
}
///getting Platform version
StructVar.WindowsVersion=(CString)info.szCSDVersion;
////getting the build number
BuildStr.Format("%d.%d.%d",nMajor,nMinor,LOWORD(info.dwBuildNumber));
StructVar.BuildNumber=BuildStr;
return 0;
}
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I forgot (like I often do) to add help to my app's settings when creating my project. I'm pretty far along in the project now, so I don't want to start over, so what do I need to do to add help now since the project is already created?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Anytime you forget to do something with AppWizard, it's usually best to create a temp project using the desired settings, and then compare to see what items your project is missing.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
yeah, I thought about doing that, but I was hoping there was an easier way!! (just lazy ) thanks!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
what message handlers uses the min,max and close button
|
|
|
|