|
If this is code, it will not work!
I assume that you are talking about the GroupBox...
Because the in OnInitDialog you are trying to draw the border, but do you know that the window is hidden at that time. You have to write the drawing code in OnPaint, which is called every time the window needs to be repainted.
Moreover it is not good practice to draw the control from another window. So I suggest you that you should derive a class from CStatic and write the code to draw the border inside it. Then create the member variable from this new class.
- NS -
|
|
|
|
|
in onpaint it doesnt work
whitesky
|
|
|
|
|
Really? You mean whose OnPaint? CStatic or CDialog?
- NS -
|
|
|
|
|
I think maybe problem is OnInitDialog so i tested in onpaint
whitesky
|
|
|
|
|
Oh...
It could be due to, painting of the control is coming after that of the dialog...
- NS -
|
|
|
|
|
huutribk2001,
why dont use from one derived class
i write for button maybe it some helpful to you
void CButton::DrawItem(LPDRAWITEMSTRUCT lpDraw)
{
CDC dc;
dc.Attach(lpDraw->hDC);
...
...
and you can use Framerect or Fillrect and ... in dc
...
dc.Detach();
}
if you want to this way you should derived from your class in example CButton and set OwnerDraw in property from your control
whitesky
|
|
|
|
|
As WhiteSky says, the class is CButton, not CStatic. In my first answer it was mentioned as CStatic...
- NS -
|
|
|
|
|
Yah,
It work with CStatic now,
Mmany thank for help.
Tri
|
|
|
|
|
i have defined in stdafx.h header abt all the versions like win95 ,98 win xp and also winnt its working fine in every os except in WINNT
#ifndef WINVER
#define WINVER 0x0400
#endif
#ifndef _WIN32_WINNT
#define WINVER 0x0400
#endif
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
|
|
|
|
|
lately i am finding that I am adding functions in the public space only.. no protected no private.. may be just to access the functions easily.. how may i remove this habbit.
tell me true practical explaination that private or protected are must
pathak
|
|
|
|
|
You can do one thing. Create a variable in the public scope that is critical to your application and you don't want the user to modify value of the same.
If this value gets modified you are stuck.
Don't allow to do this.
You will have to think the criticallity of the variable each time you are going to declare them and at the same time you need to determine their scope
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Practices are making man perfect.
so through practice, u will be perfect.
Reading is a good option to know more and correct our assumptions and mistake and also it will fill the gaps in our knowledge.
If you read Code Complete 2, Effective C++ (or similar books), u will find that what u r doing is absolutly wrong.
Define scope for all classes u r creating.
Fix the interfaces, limit it to a minimum.
The public functions are used to communicate with other modules or object. where are as we are defining private functions for some internal calculation required by other functions in the class.
Suppose there is a function in your class which draws an object in your window. you don't need to share this function to others. because it is only required when a paint message comes in your object and draws the required object. it is limited to your class.
so scope ur object with minimum interfaces. never put internal functions to public, that is nto a good way of pragramming. if it is generic and can be used for others make it public static and meaningful.
Hope u clear.
-Sarath
|
|
|
|
|
If you want that no one can access your method simply make it Private
If you want that only immediate derived class can access the methods make it protected
and for everyone make it public
for e.g
if you want that the user must pass the parameter for creation of the instance of the class then make the empty constructer as private
class test
{
public:
test(int index){index=0};
private:
test(){};
};
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
A_LaXmanKnock out 'T' from CAN'T ,
also " ' "
then it becomes CAN
|
|
|
|
|
Can you start thinking from now?;P
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
pathakr wrote: tell me true practical explaination that private or protected are must
when you don't any functionality to leak to outer class, which will corrupt the data if not properly used!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Just get in the habbit of always adding new functions in the private section first and only "promote" them to protected or lastly to public when required.
Steve
|
|
|
|
|
I have a parent window, it has a Bitmap(GDI+) data member which draws a picture as background when OnPaint is called.
I create an Edit control and type a string in it. now I want to write the string to the background picture, at the exact position the Edit control be.
how to do that? help please
I ever called DrawText in OnOK, find when OnPaint is called, my string will be covered by background. so I want to make the string be part of background picture, but I don't konw how to do. help, help, help.......
-- modified at 2:39 Thursday 18th May, 2006
|
|
|
|
|
you can see example in msdn
CString str;
CEdit m_Edit1;
m_Edit1.GetWindowText(str);
graphics.DrawString(
A2W(str),
11,
&myFont,
origin,
&blackBrush);
whitesky
-- modified at 2:01 Thursday 18th May, 2006
|
|
|
|
|
in fact, what I realy want is not type string on window directly. I have a Bitmap object, I want add the string into the picture, then every time the picture be drawed(OnPaint function be called), the string will show out.
I want the string to be part of the background picture, splice them as one picture.;)
sorry, my English not very good, sometimes I expressed wrong ideas. thank you.
|
|
|
|
|
Use DrawText or Textout API's
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
in fact, what I realy want is not type string on window directly. I have a Bitmap object, I want add the string into the picture, then every time the picture be drawed(OnPaint function be called), the string will show out.
I want the string to be part of the background picture, splice them as one picture.
sorry, my English not very good, sometimes I expressed wrong ideas. thank you.
|
|
|
|
|
When you type the text after that you can check the value of Enter Key and set make the edit control transparent.
Cheers
"Peace of mind through Technology"
|
|
|
|
|
like this
<br />
USES_CONVERSION;<br />
Graphics graphics(GetDC()->m_hDC) ;<br />
Image * img ;<br />
ImageAttributes imAttrib; <br />
img = Image::FromFile(A2W("c:\\A.jpg")) ;<br />
graphics.DrawImage(img,Rect(0,0,378,350),<br />
0,0,img ->GetWidth(),img ->GetHeight(),
<br />
CString str;<br />
str="Hello frined";<br />
<br />
Font Font(L"System", 16);<br />
PointF origin(50,50);<br />
SolidBrush Brush(Color(255,255,255));<br />
graphics.DrawString(A2W(str),str.GetLength(),&Font,origin,&Brush);<br />
<br />
whitesky
|
|
|
|
|
sorry, I think I express the wrong idea. please read my reply to other persons. thank you.
|
|
|
|