|
Hello,
I have a problem, this is the following.
I make a a form. There is a button on the form.
The form have a event execute ShowInTaskBar is false.
The Button have 3 event, 1st event is MouseLeave event, this is BackColor of it is black, 2nd event is MouseEnter event, this is BackColor of it is white, 3rd event is ButtonClick event, this is ShowInTaskBar is true.
Before I click a button, mouse event is enable. but after I do it, mouse event is disable. This condition is a button's backcolor is white, not change black yet.
private void button1_MouseLeave(object sender, System.EventArgs e)
{
button1.BackColor=Color.Black;
}
private void button1_MouseEnter(object sender, System.EventArgs e)
{
button1.BackColor=Color.White;
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.ShowInTaskbar=false;
}
private void button1_Click(object sender, System.EventArgs e)
{
this.ShowInTaskbar=true;
}
I think this is bug of .NET. But I resolve this problem. If you have some solutions, please tell me.
Cheers,
yu-yu
|
|
|
|
|
Hi there !
Im stuck with my win32 application where I want to add an bitmap to a control button in a dialog.,
Im tryin to use the BM_SETIMAGE message but I dont get it to work... I have a bitmap IDB_BACKWARD_BITMAP defined in the resource.rc and given an id in resource.h
The control button IDC_BUTTON1 that I want to attach the image to is defined in the resource.rc
here is my callback function for the dialog window that also contains an combobox etc but its not displayed here.
LRESULT CALLBACK ToolboxProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
LRESULT iComboBoxSelection;
switch(Msg)
{
case WM_INITDIALOG:
SendMessage(GetDlgItem(hWndDlg,IDC_BUTTON1), BM_GETIMAGE, IMAGE_BITMAP, IDB_BACKWARD_BITMAP);
..............
I have also tried a version where I load the bitmap like this;
Bitmap=LoadBitmap(t_hInst,MAKEINTRESOURCE(IDC_BUTT
ON1));
SendMessage(GetDlgItem(hWndDlg,IDC_BUTTON1), BM_GETIMAGE, IMAGE_BITMAP, Bitmap);
Where I have defined HINSTACE t_hInst global but is there anything else that I have to do with it? and i also get an error
"cannot convert parameter 4 from 'BITMAP' to 'LPARAM'
......
Any help would be grateful because I dont have any clue about what to do
Regrads
/Peter
|
|
|
|
|
|
I want to use wave file in my project.
When i click button,some music is appear.
|
|
|
|
|
Occam once said..
PlaySound - The PlaySound function plays a sound specified by the given filename, resource, or system event. (A system event may be associated with a sound in the registry or in the WIN.INI file.)
|
|
|
|
|
How about sndPlaySound() ?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I have open a modless dialog winodws and I need to close the window. Is I do that i works but if I try to open the dialog again it fails.
So how can I open and close a modless dialog and it works?
I have a dialog and from that dialog I need to bring up a modless dialog and close so it needs to be open and close.
This is how I have done!
Main dialog.
m_modless.create(IDD_MODLESS);
m_modless.SHowWindow(SW_SHOW);
.... And the modless dialog is shown.
from the modless dialog I try to use
OnOK(); // To close the dialog and it works but I can NOT open the modless dialog again.
And I have try to use,
CModless m_mod;
m_mod.CloseWindow(); // and this do NOT work at al.
Please help me someone.
|
|
|
|
|
The dialog you create is not the dialog you close.
So it don`t work as you want.
|
|
|
|
|
No it don't how can I fix this?
I need to close the dialog so I can open the dialog again.
Can you help me please?
|
|
|
|
|
If the window is going to be opened and closed lots of times, then it'd make sense to not close the window at all, but just hide it away
i.e.
m_modless.ShowWindow(SW_HIDE); to hide it, then m_modless.ShowWindow(SW_SHOW); to make it re-appear
(remember not to try and re-create the window when you re-show it, you only need to do that the first time you use the window)
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
|
Well I get the error: ASSERT(::IsWindow(m_hWnd));
On my main dialog I show the modless dialog and on the modless dialog I try to close it.
MAIN dialog
CModless m_modless;
m_modless.ShowWindows(SW_SHOW); // Works Greate
Modless dialog (on close )
CModless m_modless;
m_modless.ShowWindow(SW_HIDE); // Get the error.
On initdialog on the main dialog I use,
m_modless.Create(IDD_MODLESS); // To create the modless dialog.
It works to show the dialog but not to close it.
What Im I doing wrong?
|
|
|
|
|
This is because in both cases you're creating a brand new (and private to the function) instance of m_modless, so the attempt to hide the window is hiding a different (non-existing) window to the one you show'd earlier.
You need to make m_modless a member variable of your class, instead of being a variable within your show/hide functions.
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
The suggestion you got earlier about hiding the dialog is ok, but in case you do want to close it in the future so that the modeless dialog is not holding onto memory that your application doesn't need to have, this is what you should do. Make a member pointer variable of the type of your calling class in your modeless dialog's class. Alter the constructor so that it has to have a pointer of the calling class's type (make sure to use a forward declaration in your header file). Like this:
class CCallingClass;
class CMyModelessDialog : public CDialog
{
CCallingClass* m_pCaller;
};
in your constructor, set the member pointer equal to the pointer sent in. Then when you want to close the dialog, do this:
m_pCaller->SendMessage(WM_USER_CLOSE_MODELESS);
In your stdafx.h file,
#define WM_USER_CLOSE_MODELESS (WM_USER + 1001)
Add a message map entry for your #defined message like any other message, and map it to the appropriate function. In that function, do this:
m_modless.DestroyWindow();
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
Well I get the error: ASSERT(::IsWindow(m_hWnd));
On my main dialog I show the modless dialog and on the modless dialog I try to close it.
MAIN dialog
CModless m_modless;
m_modless.ShowWindows(SW_SHOW); // Works Greate
Modless dialog (on close )
CModless m_modless;
m_modless.ShowWindow(SW_HIDE); // Get the error.
On initdialog on the main dialog I use,
m_modless.Create(IDD_MODLESS); // To create the modless dialog.
It works to show the dialog but not to close it.
What Im I doing wrong?
|
|
|
|
|
Larsson wrote:
from the modless dialog I try to use
OnOK();
You most override OnOK() (and OnCancel() ) in order to close a modeless dialog. Do not call the base class OnOK() , which calls EndDialog() , but call DestroyWindow() instead.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Well I get the error: ASSERT(::IsWindow(m_hWnd));
On my main dialog I show the modless dialog and on the modless dialog I try to close it.
MAIN dialog
CModless m_modless;
m_modless.ShowWindows(SW_SHOW); // Works Greate
Modless dialog (on close )
CModless m_modless;
m_modless.ShowWindow(SW_HIDE); // Get the error.
On initdialog on the main dialog I use,
m_modless.Create(IDD_MODLESS); // To create the modless dialog.
It works to show the dialog but not to close it.
What Im I doing wrong?
|
|
|
|
|
CModless *modeless = new CModless;
modeless->ShowWindow(SW_SHOW);
void CModless::OnOK()
{
DestroyWindow();
}
void CModless::OnCancel()
{
DestroyWindow();
}
void CModless::PostNcDestroy()
{
delete this;
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I have open a modless dialog winodws and I need to close the window. Is I do that i works but if I try to open the dialog again it fails.
So how can I open and close a modless dialog and it works?
I have a dialog and from that dialog I need to bring up a modless dialog and close so it needs to be open and close.
This is how I have done!
Main dialog.
m_modless.create(IDD_MODLESS);
m_modless.SHowWindow(SW_SHOW);
.... And the modless dialog is shown.
from the modless dialog I try to use
OnOK(); // To close the dialog and it works but I can NOT open the modless dialog again.
And I have try to use,
CModless m_mod;
m_mod.CloseWindow(); // and this do NOT work at al.
Please help me someone.
|
|
|
|
|
destroy it and re-create it...
You can however find more info on modeless dialogs on MSDN.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Should I destoy the dialog like this?
CModless m_mod;
m_Mod.DestroyWindow
|
|
|
|
|
Well that dont work I get this error code;
ASSERT(pWnd->m_hWnd == NULL); // only do once
|
|
|
|
|
Hi,
I've done the modeless dialog thing once and what I can remember was that you had to recreate the thing, I just can't remember how I did it, but I've found it in literature then, so I'll bet you can find it too.
Search for some sample code on the net or in some MFC book or something.
Sorry I can't remember more than this, it's been a long time.
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
|
If an Abstract Base Class is never going to be instantiated, why do some have ctors in them (ctors which have nothing to do with the ABC)?
To me, it'd be clearer to see those activities occurring in the derived class(es).
William
Fortes in fide et opere!
|
|
|
|