|
Yes, I have used a treecontrol, and subclassed it to my own view derived from CScrollView, By using a treecontrol, you don't have to worry about not getting all mouse actions and things like that.
So yes it can be done!
|
|
|
|
|
Can you possibly provide some sample code?
I tried the article mentioned above and it asserts in wincore.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi John,
In an app I am currently working on which is MDI, I wanted each MDI View to be a CFormView with a dialog resource. The problem I had was making the window look like a dialog box. I was trying to port the look and functionality of an Access form into an MDI arcitecture.
I had to modify the CChildFrame and the main CFormView derived classes.
If this sounds like what your looking for I can send you the sample code.
Giles
|
|
|
|
|
Actually, all I need is a place to draw some stuff (using GDI calls and such). It doesn't have to scroll, it doesn't need to respond to mouse clicks, it doesn't even need to open a document. I think I'll try just creating a CWnd and attaching it to the dialog somehow.
I figured using a CView would be easier, but it's been a pain in the ass.
Let's also not forget that this is a dialog-based app where I did not elect to support doc/view.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I wrote ActiveX with ATL,I add background color
property when I insert control into project,How can I add
property sheet,for this stock property?
|
|
|
|
|
Try adding
PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
in between your BEGIN_PROP_MAP and END_PROP_MAP in your header file.
HTH
Jignesh
|
|
|
|
|
I have several applications that use custom CWnd controls. And for some reason, when I use GetDC() and ReleaseDC() while handling a WM_PAINT message, as soon as OnPaint() is done, it gets called again. This craziness seems to go away when I use a local CPaintDC.
Trouble is, I'm now trying to fix an old app that uses a seperate thread to handle the drawing. OnPaint() puts a custom PAINT message in a queue for the thread, which in turn uses GetDC() on a hWnd (GetSafeHwnd()). I can't seem to construct a CPaintDC without MFC ASSERTing that the CWnd is invalid.
void OnPaint() {
queue.PushEvent(PAINT, currentRange);
}
int ThreadProc(CWnd *pWnd) {
while(1) {
t = queue.PopEvent();
switch(t) {
case PAINT:
HWND hWnd = pWnd->GetSafeHwnd();
HDC hDC = GetDC(hWnd);
CDC *pDC = CDC::FromHandle(hDC);
...
ReleaseDC(hWnd, hDC);
break;
...
}
}
}
When I try CPaintDC dc(pWnd), it ASSERTs.
So...
Q1) Has anyone else ever seen the never-ending stream of WM_PAINT messages? And if so, any idea how to prevent it?
Q2) Can anyone come up with a nice way of creating a CPaintDC from a CWnd inside a thread? I can't easily (and safely) create the DC outside the thread and pass it in.
J
|
|
|
|
|
Found CWnd::BeginPaint() and CWnd::EndPaint(). That got rid of the never-ending messages. I'd still like to know what that happens...
I have other problems remaining, but I'm pretty sure they're unrelated.
Anyone else out there detest debugging other people's old ugly code?
J
|
|
|
|
|
Hi,
I have got a dialog(CDialog). In OnInitDialog() I create second dialog(CPropertyPage), which is child of first dialog. When I execute app, second dialog is redrawed only when I resizing the app window ?? Why ??
(routeing messages ?? )
|
|
|
|
|
Does the second dialog appear at all, or is this just a problem with the redraw. You'll have to post your code so we can see what is wrong.
Michael
|
|
|
|
|
Ufff Its now ok,but :
Where must i write the code for painting dialog background ? When i put the code in OnPaint(), all control are redrawed by background.
|
|
|
|
|
OnEraseBkgnd.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Wizard_01 wrote:
Where must i write the code for painting dialog background ?
Handle WM_ERASEBKGND and paint the background in that handler.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Suppose IDC_EDIT1 is the ID of the edit box, so if i do
if (GetDlgItem(IDC_EDIT1)->IsKindOf(RUNTIME_CLASS(CEdit)))
AfxMessageBox("Type of the class is CEdit");
Message should be displayed.but it is not displaying.
I want to check the type of control, and i have only CWnd pointer , what should i do.
EXPLANATION
............
I have a CWnd Pointer and from this pointer i want to check what was the type of the control,whether it is CEdit, or CButton etc.
what should i do
|
|
|
|
|
The use of RUNTIME_CLASS may not return the right stuff for ya because you perhaps haven't declared DECLARE_DYNAMIC, DECLARE_DYNCREATE, or DECLARE_SERIAL in your class:
"RUNTIME_CLASS returns a pointer to a CRuntimeClass structure for the class specified by class_name. Only CObject-derived classes declared with DECLARE_DYNAMIC, DECLARE_DYNCREATE, or DECLARE_SERIAL will return pointers to a CRuntimeClass structure." <-- From MSDN Library
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
if (GetDlgItem(IDC_EDIT1)->IsKindOf(RUNTIME_CLASS(CEdit)))
AfxMessageBox("Type of the class is CEdit");
...is never going to work because...
CWnd *p_MyWnd=GetDlgItem(IDC_EDIT1);
CRuntimeClass *p_RTC=p_MyWnd->GetRuntimeClass();
in the debugger shows p_RTC to be a kind of CTempWnd. Your class is of no particular type until your pointer is cast as the desired type. Basically, GetDlgItem(IDC_EDIT1) is NOT a CEdit, until you cast it as CEdit.
Of course, this doesn't help you much, but it might help you sleep at night
My tuppence aimed at actually solving your problem though:
work out the window class (not the same as a C++ class.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I recommend you use the window's class name instead:
CString strClassName;
::GetClassName(GetDlgItem(IDC_EDIT1).GetSafeHwnd(), strClassName.GetBuffer(100), 100);
strClassName.ReleaseBuffer();
if (strClassName == "EDIT")
AfxMessageBox("It's an edit box");
Take a look at CreateWindow for a list of possible class names.
Regards,
Alvaro
|
|
|
|
|
Take a look at CreateWindow for a list of possible class names....
.... or play with Spy++. Spy++ really is great. Anyone want to form the Spy++ appreciation society with me?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I have a BMP file- MyBmp.BMP.
How can I display it grayscaled ?
I'm will use MFC if I'll need but I must see it grayscale.
10x.
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
Use photoshop or paint shop pro to greyscale it first?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Were did my reply go ? Anyhow, I said that you can use Paintlib, or add a gray function to Chris's DIBSECTION wrapper. The latter is probably faster.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
i really like to know much bout things i use.. and today there are enums..
i've tried to find some informations in 3 sources (msdn, stroustrup the c++ programming language and thinking in c++).. and i couldn't really find an answer for my questions..
* what is the difference between named and unnamed enums
enum num1
{
value1
};
enum
{
value2
}
* do i HAVE to call them qualified ? (num1::value)
* what is the big advantage of using enums instead of #defines (outside of classes)
* "thinking in c++" said that you should use static const - var's instead of enums, is this really better ?
i hope somebody can help me to answer these questions..
thanks in advance
Bernhard
"There are three roads to ruin: women, gambling and technicians. The most pleasant is with women, the quickest is with gambling, but the surest is with technicians." Georges Pompidou
|
|
|
|
|
The greatest atvantage about enum is that compiler (C++'s) does strong type
checking on'em.
take e.g.:
enum Days{SUNDAY, MONDAY,...};
void MyClass::CheckDay(Days day)
{
switch(day)
case SUNDAY : cout << "Sunday";
//.....
}
(We know that SUNDAY == 0)
MyClass dayChecker;
dayChecker.CheckDay(0); //Compiler error: The method expects to
// receive Days data type
dayChecker.CheckDay(SUNDAY); //This will.
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
<eom>
"There are three roads to ruin: women, gambling and technicians. The most pleasant is with women, the quickest is with gambling, but the surest is with technicians." Georges Pompidou
|
|
|
|
|
Bernhard wrote:
* "thinking in c++" said that you should use static const - var's instead of enums, is this really better ?
I hate blanket statements like that... Enums should be used for what they are meant for -- enumerations. That is, they should be used when you need to represent a set of values, but don't really care what the values are:
enum ACTION
{
PRINT,
PREVIEW,
EXPORT
};
void DoOutput(const char* OutputDataString, ACTION action)
{
switch (action)
{
case PRINT:
...
break;
case PREVIEW:
...
break;
case EXPORT:
...
break;
}
}
In the example above, it doesn't matter what the values of PRINT, PREVIEW, and EXPORT are, only that they are different. As the other post mentioned, the compiler will perform type checking on this to ensure that only valid values are passed into the function (of course you could use a cast, but you'd never do that right?).
In cases where the value of a constant is actually important, you should use a static const -- not only does this let you be consistent about your constants, since enums are only good for ints anyway, it is also safer, since if the value is important, sooner or later you'll need to convert it from something else, and assigning an int to an enum variable is (i think) undefined (though it usually works). If you need some extra type checking in this case, you're better off using a typedef or even a wrapper class.
Just my $.02
|
|
|
|