|
Hi
i am working with mfc.
in the onpaint in a cdialog, i need to draw some shapes and for each i need to add a button to it. the user can add more of this shapes and also for each new shape there is a button
i was able to create the button in onpaint but clicking it causes the app to freeze
is there any solution for this, or any other approach for adding the button
thanks alot
|
|
|
|
|
Waw, this is... bad ! You know that OnPaint will be called each time the app needs to be refreshed ? So for example, a windows comes before your app and then disapear, then OnPaint will be called again. Thus you will create new buttons over and over again... This is crazy.
You should create the buttons once only, at the creation of the window.
|
|
|
|
|
excuse me
you draw some shapes and you create buttons in the WM_PAINT and when you click in the button they are freeze.
buttons are controls for shapes?
you can once buttons and use them
I think Its not good create button in wm_paint
|
|
|
|
|
I know that creating controls in wm_paint is bad and crazy and waw.
Each shape on the dialog has a button (drawn inside the shape) to do some action on the shape.
but lets suppose that i have one shape now, and i created its button outside the wm_paint.
now in run_time the user will add new shape,
but how i ll create a new button to associate with the new shape?
|
|
|
|
|
|
I suggestion
Use HWND hwnd[20];
if user will add new shape then user use WM_LBUTTONDOWN
and you can then create button if you need use handle button in the onpaint
|
|
|
|
|
I think you need to re-think your design; you simply cannot create controls in the OnPaint.
in your main view, you will draw an OBJECT.
that OBJECT will be a class ( CWnd derived ) that will take care of creating/owning its Button and drawing the shape.
for example, a rough implementation :
class CButtonShape : public CWnd
{
DECLARE_DYNAMIC(CButtonShape)
CBrush m_Brush;
CButton m_Button;
public:
CButtonShape();
virtual ~CButtonShape();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
and use the view to create and display that class ( or many as you wish ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi all,
Do anybody know why the font size is normally said as 8, 10, 12, 14, 16, 18, 20, 24, 36, 48, etc?
Is there any speciality for these numbers?
- NS -
|
|
|
|
|
|
This is a new knowledge to me.
Thanks a lot.
- NS -
|
|
|
|
|
I am displaying the directories and files in ListView on clicking the treeview node.But on clicking the listview item
it does not shows the subitems in listview.
Can somebody please send the any link or code ?
|
|
|
|
|
|
How to test TCP/IP connection on the client-side? Some software needed (Win32).
Thanks
Rose
|
|
|
|
|
I like this tool: http://www.protodevelopment.com/en/index.html
|
|
|
|
|
|
Hi friends
Please look at following questions.
1) Can I get list of printers and print servers from active directory. If yes how?
2) Can I monitor printer jobs for a shared printer installed on some different machine.
3) Can I abort above kind of jobs
4) Can I modify above kind of printer jobs and add watermark or user name?
Thanx
VikramS
|
|
|
|
|
i'm using fread to read a file ,and get all the characters in file into a buffer.
char buffer1[nfilelength];
numread=fread(buffer,sizeof(char),1,"text1.txt");
then when i compile, an error occured need me to put a constant integer in declaration of char buffer[], how can i do coz the file length is dynamic.
HelpMe
|
|
|
|
|
Allocate buffer1 with new.
And don't forget to delete it, later.
|
|
|
|
|
rather than putting nfilelength in buffer1[] put some value say buffer1[512]
never say die
|
|
|
|
|
To specify an array with dynamic size, you should allocate it dynamically.
eg.
char* buffer1 = new char[nfilelength];
// read the file.
// do other thing that you need.
delete [] buffer1;
But I think there is a logical mistake in your code. You read only one char from the file using fread. If you intended to do so then you don't have to give any array.
If not you should specify the size as nfilelenght or sizeof(char)*nfilelength instead of sizeof(char).
- NS -
|
|
|
|
|
What is the difference between ItemExpanding and ItemExpanded in treeview ?
Thanks
|
|
|
|
|
pankajgarg12 wrote: What is the difference between ItemExpanding and ItemExpanded in treeview ?
MSDN has explained the difference quite nicely.
Nibu thomas
Software Developer
|
|
|
|
|
|
TVN_ITEMEXPANDING is sent before the expand/collapse happens, and gives you the chance to prevent the change. TVN_ITEMEXPANDED is sent after.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
IF i have a array which contains the color values then how to create a bit map using that array.
eg. unsigned char Arr[ROW][COL][3];
Arr contain Row*Col*RQuad valus;
then i create a BITMAPFILEHEADER, and BITMAPINFOHEADER
and these two a erite into a file, then i face aproblem how to write a color value in file so that .bmp file will generate.
Thanks in advance
Rahul here
|
|
|
|