|
When i resize the dialog, the dialog content are redrawed. However, when i click on tiltle bar and drag the dialog the window is not redrawed .... how can i redraw after moving/draging a dialog from one place to another.?? can i handle Mouse WM_LBUTTONUP. how can i do please help. I am using VC++.2005 with MFC dialogs.
|
|
|
|
|
How could you define,
that the window does not redraw itself, please ? virtual void BeHappy() = 0;
|
|
|
|
|
Use a Boolean member variable in your dlg class and initialise it as FALSE. Set it as TRUE in left button Down event. Then check it in the mouse move. If it is true then redraw the dlg contents. Also set it as FALSE in the left button up event.
eg:
BOOL m_bClicked=FALSE;
LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_bClicked=TRUE;
return 0;
}
LRESULT OnLButtonUP(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_bClicked=FALSE;
return 0;
}
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if(m_bClicked)
{
}
}
|
|
|
|
|
What is the Base class of your dialog? Is it CDialog? Or is it a class derived from CDialog?
|
|
|
|
|
it is class Derived from CDialog.
|
|
|
|
|
What all messages is your derived class handling like
(WM_MOVE, WM_MOVING, WM_PAINT)
If possible please post the code..
|
|
|
|
|
No i am not Handling messages WM_MOVE, WM_MOVING, WM_PAINT for this. thats what i am asking which message fuction should i handle.
|
|
|
|
|
Actually you need not handle any of these messages, because CDialog will do it for you.
This post is duplicate post of your previous question.didn't the solution posted in previous question help you. I have created a sample, and it's working fine
|
|
|
|
|
HI
i am using VC++ 2005
I have a BYTE of data, which is of 8
bits 76543210
.....this BYTE consist of 3 fields in it, which are as follows...
field 1.... bit 0-3
field 2.... bit 4
field 3.... bit 5 6 7
Now I want to extract all these 3 fields and store in 3 differernt variable....
please provide me an efficient way to do it...
thanks in advance
|
|
|
|
|
|
|
Read up on unions and structures - that's the elegant way to do it.
Bitwise-and and right-shifting (suggested by the previous poster) will also do the job nicely.
|
|
|
|
|
field1 = (data & 0x0F);
field2 = (data & 0x10) >> 4;
field3 = (data & 0xE0) >> 5;
|
|
|
|
|
A bit more optimization in field3
«_Superman_» wrote: field3 = (data & 0xE0) >> 5;
field3 = data>> 5;
|
|
|
|
|
Perfect.
|
|
|
|
|
The two different ways (you may find they are translated to the same asm, by the compiler).
[update] the first method's asm (SHIFT and AND operator) looks slightly faster)[/update]
struct BitField
{
unsigned int f1:4;
unsigned int f2:1;
unsigned int f3:3;
};
union MyData
{
unsigned char data;
BitField bf;
};
int main(int argc, char *argv[])
{
unsigned char data= rand();
int field1, field2, field3;
field1 = data & 0xF;
field2 = (data >> 4) & 1;
field3 = data >> 5;
printf("data=%d\n", data);
printf("(1) fields: %d, %d, %d\n", field1, field2, field3);
MyData md;
md.data = data;
field1 = md.bf.f1;
field2 = md.bf.f2;
field3 = md.bf.f3;
printf("(2) fields: %d, %d, %d\n", field1, field2, field3);
return 0;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Wednesday, March 10, 2010 5:31 AM
|
|
|
|
|
field 1.... bit 0-3 = > (data & 3)
and so onPress F1 for help or google it.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: field 1.... bit 0-3 = > (data & 3)
field 1.... bit 0-3 = > (data & 15)
FFY.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have created 3 modeless child dialogbox dynamically on Parent dialog,
CDialogBoxDlg *m_Sel[3];
for(int i=0;i<3;i++)
{
m_Sel[i]=new CDialogBoxDlg();
m_Sel[i]->Create (IDD_DIALOG,this);
m_Sel[i]->ShowWindow (SW_SHOW);
}
after creating ,if i click on title bar and move the dialog1 or dialog2 or dialog 3,then it will not look clearly,if i Resize the Border then it will looks clearly.
i tried Invalidate(), UpdateWindow() and RedrawWindow() then also it is not working please help.
-- Modified Wednesday, March 10, 2010 4:12 AM
|
|
|
|
|
Did you call UpdateWindow in this way
for(int i=0;i<3;i++)
{
m_Sel[i]=new CDialogBoxDlg();
m_Sel[i]->Create (IDD_DIALOG,this);
m_Sel[i]->ShowWindow (SW_SHOW);
m_Sel[i]->UpdateWindow();
} modified on Wednesday, March 10, 2010 3:59 AM
|
|
|
|
|
Also, you need to have an array of 3 locations - CDialogBoxDlg *m_Sel[3];
The valid locations are now from 0 to 2
|
|
|
|
|
I am creating a blocking API implementation. For that i am using a semaphore which is initialized once in the beginning of the program. A pseudo code of the scenario is given below:
startProgram()
{
initCount = 0; //first call shall wait
semVariable = CreateSemaphore (NULL, initCount, 1, NULL);
}
I am calling the semaphore in my API:
API_my_blocking_func()//thread1
{
//Wait until data is ready in do_unblock()
if(WAIT_TIMEOUT == WaitForSingleObject (semVariable, timeout)
{
return WAIT_TIMEOUT ;
}
continues........
}
meanwhile in another thread, when data is ready, I am releasing semaphore so that API_my_blocking_func() continues.
do_unblock() //trhead2
{
if(data is ready)
ReleaseSemaphore (semVariable, 1, NULL);
}
----
Now I am having a problem : If ReleaseSemaphore (with semVariable) is called two times due to some reason,
the WaitForSingleObject is not waiting!
To my expectation, since the maximum count is set to 1 , releasing the semaphore
shall not increment semVariable above 1, whatever be the number of calls to ReleaseSemaphore . So the very next
WaitForSingleObject shall block.
How to achieve multiple release of semaphore is allowed, and a single WaitForSingleObject on the same semaphore shall block?
|
|
|
|
|
its not clear what do you need. whenever the semaphore is released its count is increased and a WaitForSingleObject() will be unblocked. If you need to wait till a set of flags are signaled, use array of events or mutexes and use WaitForMultipleObjects()
|
|
|
|
|
Since 'maximum count is set to 1' during semaphore initialization, when semaphore is released its count is increased to 1 only. Not beyond (is this true?). So n number of releases shall keep maximum count 1. And next wait shall decrement by 1 and thus block.
What I observed is : If i release same semaphore multiple times, I cannot wait on that semaphore in a single wait call.
|
|
|
|
|