|
yogish293 wrote: i tried to insert all menu item but its taking time to insert and after that my PC got restarted..
Well that should give you a clue that those of us who are suggesting that you need to rethink your design may actually have a point.
I must get a clever new signature for 2011.
|
|
|
|
|
And you think it's a good idea ?
Anyway, it's probably some sort of "ownerdrawn" nenu.
I could suggest you have a look at the Firefox/Mozilla source code.
Watched code never compiles.
|
|
|
|
|
This is essentially a repost of the same question[^], were the answers there not helpful?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Hello Friends
I am loading an image.Now I want to Load another image that I want floating over the first so that i can move when i want.Do I need to get Some DC Or any other Idea?
I m confused Do i need to create a new DC or by using the Existing DC?
Thanks & Regards
Yogesh
|
|
|
|
|
For flicker free drawing, you may use a memory dc to draw two images and BitBlt it into the window dc.
yogeshs wrote: so that i can move when i want.
You mean by means of mouse?
|
|
|
|
|
Yeah,I want to move by mouse.
And Does By getting Memory DC ,the second image will be a floating image?
Thanks For Reply.
Regards
Yogesh
|
|
|
|
|
yogeshs wrote: By getting Memory DC ,the second image will be a floating image?
It doesn't mean.
If your requirement is simple, better to draw the floating image on another window, probably a child one without borders and title. Size this window to same size as image. Use WM_NCHITTEST message to enable the moving of this window by dragging the mouse anywhere in client area. (From NCHITTEST message handler, if the mouse coordinate is with in the window rect, return HTCAPTION to accomplish this)
Otherwise, once both the images are rendered to the same window dc, you have to manually handle mouse clicks and mouse moves which comes inside the second image, and redraw it appropriately. For this to work smoothly, you may first draw to a memory dc and then BitBlt to window dc.
|
|
|
|
|
I am trying to get the document idispatch. Note that I already know the hwnd for each instance of the application that I am interested in, but cannot get the right application idispatch with multiple application instances running. The GetDocDispatch method, referred to in the article referenced below, displays a message with the idispatch. How can I call the GetDocDispatch method or access the values from native C++?
http://support.microsoft.com/kb/190985/[^]
modified on Wednesday, January 12, 2011 4:16 AM
|
|
|
|
|
hi all,
following is a code snippet of my program having vc6 mfc sdi and formview as basic characteristics.
void CScada_thrdsView::dsp_cnt()
{
while (!exit_thrd)
{while(!nw_cnt) ;
sprintf(cstring,"%d",count);
m_val.InsertString((count-1),cstring);
UpdateData(FALSE);
` nw_cnt = 0;
}
}
i am getting an error
debug assertion failed;file wincore.cpp;line no 883
from debugging i gather that this error is being caused due to the updatedata statement.
the function dsp_cnt is in form view but is being called from the worker thread.
i request for help in sorting out this error.
thnx
ashwani
|
|
|
|
|
You cannot manipulate UI elements from a non UI thread. I suggest you read this excellent article[^]. It's a bit long but it is really worth reading it, because you will learn a lot of very useful things.
|
|
|
|
|
|
I would guess it is 1 of 2 problems.
1. Most likely that they belong to a different thread (the main thread). To my knowledge, UpdateData must be called from the thread that owns the controls.
2. The controls haven't been created yet, if it is in initialisation code.
The best way I would suggest for fixing problem 1 would be to register a custom message WM_USER + 1 and have the handler call UpdateData like this:
header file:
#define CM_UPDATEDATA WM_USER + 1
class CScada_thrdsView : public BaseClass {
protected:
afx_msg LRESULT OnUpdateData(WPARAM wParam, LPARAM lParam);
}
source file:
BEGIN_MESSAGE_MAP(CScada_thrdsView, BaseClass)
ON_MESSAGE(CM_UPDATEDATA , OnUpdateData)
END_MESSAGE_MAP()
LRESULT CScada_thrdsView::OnUpdateData(WPARAM wParam, LPARAM lParam) {
UpdateData((BOOL)wParam);
return 0;
}
in the thread:
void CScada_thrdsView::dsp_cnt() {
while (!exit_thrd) {
while(!nw_cnt);
sprintf(cstring,"%d",count);
m_val.InsertString((count-1),cstring);
PostMessage(CM_UPDATEDATA, FALSE);
nw_cnt = 0;
}
}
|
|
|
|
|
thnx andrew.xtremely detailed help.
thnx
|
|
|
|
|
hi andrew,
i did as directed,and it worked. thnx.one small point though,in this code UpdateData((BOOL)wParam); probably should'nt it be lParam instead of wParam.
thnx
ashwani
|
|
|
|
|
No, wParam is correct.
The function I used to send the message was CWnd::PostMessage(UINT Msg, WPARAM wParam = 0, LPARAM lParam = 0);
Using the Msg as CM_UPDATEDATA and wParam as FALSE (or TRUE if you want to update the variables instead), and lParam as its default unused value of 0
Hence the wParam variable in the CScada_thrdsView::OnUpdateData function is the 1 that holds the bSaveAndValidate parameter to UpdateData.
You can change it to use the lParam by using PostMessage(CM_UPDATEDATA, 0, FALSE); to send the message if you prefer
|
|
|
|
|
|
Is there a way to measure richedit height? I should put CRichedit into fixed width window, but I should avoid vertical scroll. So, I should calculate the CRichEdit(with text) height for a specified width. Is it possible?
Pavel Sokolov
|
|
|
|
|
You could use GetWindowPlacement[^] to determine the height; the rcNormalPosition member of the WINDOWPLACEMENT structure has the info you're after.
Then SetWindowPlacement[^] to adjust it if needed.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
I need it before creation of actual control.
Pavel Sokolov
|
|
|
|
|
Okay so instead of measuring it, it should be calculated.
What is known to base the calculation on? The number of lines that are going to be in the control?
If so, you should multiply the number of lines with the height of a line, depending on the font, and add an offset of a few pixels for the border.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Nothing. I have only width of the control. The lines can have different styles and fonts and even with pictures.
Pavel Sokolov
|
|
|
|
|
So what exactly decides then how high you want it to be?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
The text in the control. I want to fit richedit into item of another control without vertical scrollbar.
The main idea is to build messages archive (history for IM). There can be a lot of messages and they are in rtf. Currently I'm trying to insert RichEdit into ListBoxItem and I need width and height for MeasureItem().
Pavel Sokolov
|
|
|
|
|
|
Pavel Sokolov wrote: Is there a way to measure richedit height?
You mean something like GetWindowRect() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|