|
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
|
|
|
|
|
Bernhard wrote:
what is the difference between named and unnamed enums
A named enum creates a type name along with the enumerator values. Just as writing "struct x {};" creates a type called "x".
Bernhard wrote:
do i HAVE to call them qualified ? (num1::value)
No, the symbol "value1" is at the same scope as the enum itself. An enum does not create a nested scope like a namespace does.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Where can one fine proper documentation for the interfaces that one needs in creating AddIns for Visual C++ 6 e.g. IDebug, IDocument. I have looked at the MSDN library but when one compares it to the header files the are many functions that aren't found in the descriptions?
Thank you
Franz Klein
|
|
|
|
|
Hello,
I have a dll created in VC++. When I run the program which uses that dll then it displays error. On debugging, it indicates that in calling any resource related function from dll, it gives error. e.g. when I call the function AfxGetResourceHandle() from dll, it displays the error dialog box of 'Abort, retry, ignore'.
The resource file for dll looks to be OK. there no error or warning on the compilation.
Can anyone please tell me why it might happens.
All suggestions are welcome,
It is urgent,
Thanx,
Vikram.
|
|
|
|
|
Hi,
I want to store some user settings, but not in the registry. I want to have a .INI file in my apps folder. I've seen that the MFC provides methods to read and write from WIN.INI . Is there anything similar so that I can write in my own app.INI file or do I have to do it 'by hand' ?
Thank you for your help !
Jerome
|
|
|
|
|
Look at WritePrivateProfileString in MSDN.
Michael
|
|
|
|
|
1. Take a look at CWinApp::m_pszProfileName. Use that to set the name of the INI file.
2. Use CWinApp::GetProfileString, CWinApp::GetProfileInt, CWinApp::WriteProfileInt, or CWinApp::WriteProfileString to read/write to the file.
Regards,
Alvaro
|
|
|
|
|
Hi,
I have one problem in my application.In my application i am using two threads.The program is working fine.But the problem is when i am running the application is taking 100% of cpu utilization.So,In the previous time there is no second thread.The first thread it self is taking 100% cpu utilization.After creating the second thread the same application is taking 100% cpu utilization.I observed that this is because of first thread.I placed Sleep(1) in that first thread the cpu utilization is reducing but the problem is it is working very slow.So,i want medium of those,ie application executing is intermediate and cpu utilization is 50%.But i am not able to reach the concept.Can anybody give some solution how i can solve my problem.;)
it is a company which deals with AI and different
types of web based applications
|
|
|
|
|
Yo guys,
I got a lit' problem here with the text drawin', hope y'all can help me out.
I've made myself a bitmap class, it can load bitmaps, it can manipulate bitmaps, and things like that, without touchin' HDC. Alright? So I'll be touchin' HDC only at the final stage, that's when I draw out the bitmap to the screen.
So the problem now is, I can't draw text onto my bitmap class, before it goes out to the HDC. That means, I have a bitmap, I draw it out to the HDC, THEN only I'm able to draw text with HDC. This causes the text to flicker EVERYTIME when I refresh the bitmap.
Just wonderin', if there's any ways to draw those texts, onto the bitmap (without touchin' HDC) before output to the screen (HDC)? I believe there is, like in Flash, I think they use their own bitmap manipulation classes, and draw text on those bitmaps, and FINALLY output the result to the HDC.
Hey, thanks dude for your time, hope y'all can help me out
Zee ya!!
Me,
Baling.
|
|
|
|
|
There are two main things which could cause flickering :
1.) Not using a memory HDC/CDC when updating the bitmap or text.
2.) Not overriding OnEraseBkgnd in your View class.
The problem is probably caused by no.1 since otherwise your whole bitmap would flicker upon refresh too. What I think maybe happening is your program is drawing the bitmap directly to the screen, quickly followed by the text. This leaves a very very short period in which you see just the bitmap, thus a flickering effect is caused. What I recommend you do is create a new CDC called SrcDC, and use CreateCompatibleDC(NULL), and select the bitmap into it. I would then create another dc called DestDC (in same way), and BitBlt the SrcDC to the DestDC. I would then draw the text onto the DestDC (this has the effect of drawing onto the class) using DestDC's TextOut() function, before *finally* BitBlt'ing the DestDC to the screens *pDC that is found in your OnDraw routine. Basically *only* the final image should be drawn to the screen in 1 BitBlt, there shouldn`t be any other routines which draw to the same *pDC after this or else flickering may occur. Hope this helped,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Alan, thanks for the solution. So it goes like this:
SrcDC --> DestDC --> DestDC.DrawText() --> pDC->BitBlt(DestDC)
But usin' this approach, the final stage will involve the transferin' of the whole DestDC to pDC, right?
pDC->BitBlt(..., &DestDC, ..., SRCCOPY);
This will be heavy, because the interface redraws itself quite frequently (i.e. mouse movements makes the button change background, and stuff like that). I know InvalidateRect, but my bitmap class doesn't handle that, it will still draw the whole background all over again.
And I'm takin' over the whole dialog's paintin'. That means the background will even go up to the screen size, which might be 1024x768! (The whole window will repain, when resized, even InvalidateRect won't help in this case.)
I've tried that approach, but seems slow, maybe I should use InvalidateRect whenever possible. Thanks again for your solution man
Me,
Baling.
|
|
|
|
|