|
Try calling GetForegroundWindow instead.
|
|
|
|
|
Hi,
I'm just moving from MFC to .NET. In MFC, I can easily intercept any message with PreTranslateMessage and do whatever i want with a particular msg. This is especially useful if a user presses the Escape button in a dialog. before all input is gone, i can ask the user if he/she really wants to proceed and discard all input. Should be no problem in .NET neither, i thought. But either it'S so obvious i just can't see it or it's not so easy after all(which would be a surprise since this is a frequently occurring scenario). What i do in respect to the Escape Button: it's assigned the DialogResult.Cancel value and the containing form sets this button's variable name as CancelButton.
Any suggestions from someone?
Thank's in advance!
Wolfgang Puelm
|
|
|
|
|
When you drop a button on the form, you can then set the CancelButton property of your form to that button. It means that when escape is pressed the event handler of that button will be invoked. The dialogresult for that button will be set to Cancel.
|
|
|
|
|
Hi,
thank you very much for your propmpt answer!
But I'm afraid that's not my problem since the default event handler gives me no chance to remove this event (ESC pressed) from the form's message processing queue. That means the dialog will be inevitably be closed and that's what i'm trying to prevent if desired by user input. If this handler had a KeyEventArgs parameter instead of a EventArgs, the KeyEventArgs.Handled property could be set to true which might do the job (if it's passed by reference). Unfortunately, the event handler is implemented as it is.
Once again, thank you for your effort!
Regards
Wolfgang Puelm
|
|
|
|
|
For this I would normally handle the FormClosing event. You'll then get the opportunity to find out why the form is closing by checking the DialogResult property. You should normally make the Cancel button, the Escape key, and the X button in the top-right corner all do the same thing.
If you really want to go down the PreTranslateMessage route, you can implement the IMessageFilter interface and use Application.AddMessageFilter to have the framework call your filter function for each message.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Hi,
Thanks a lot for your answer!
It took me on the right track - at last:
The xxx_FormClosing event has a FormClosingEventArgs parameter. From the MSDN i found out that there is a CancelEventArgs param also. Since it's possible to cast the FormClosingEventArgs into a CancelEventArgs, the latter's Cancel property can be used: if set true, the dialog stays alive, other it get's closed!
Thank's again!
Regards.
Wolfgang Puelm
|
|
|
|
|
can anyone tell me how I can create a new shell for windows xp embedded
I want complete detail regarding this i.e. how do we apporoach this problem, what are the basic skills required and which tools are helpful
|
|
|
|
|
sresth wrote: I want complete detail regarding this
So basically, you want somebody to code this up for you.
sresth wrote: how do we apporoach this problem, what are the basic skills required and which tools are helpful
If you can't answer these questions then this project is much too ambitious for you.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
u can set any windows form as the startup shell with gpedit.msc
take a look at this article :http://www.codeproject.com/useritems/CF_kiosk_mode.asp
|
|
|
|
|
I want to highlight an item in the ListBox, i.e. make its font bold or make its color green, no matter. I read about the DrawItem event, but unfortunately this item happens only when some action with ListBox is performed, but I want to highlight an item on checking a checkbox that is not in the ListBox.
|
|
|
|
|
I figured it out, I just use the DrawItem event for manual painting of the control and invoke this event by using the Refresh() method of ListBox .
|
|
|
|
|
Hi
VC++ 2005 EE
I'm writing an app which is going to display some 3D figures on System::Windows::Forms::Panel^ panel
The problem:
I've written my own class which handles all OpenGL stuff. So all I have to do is:
Create new 3D figure object, and draw it with panel's Paint method.
Constructor needs panel's HWND, so i did something like this:
TFigure *Figure;
Figure = new TCuboid( (HWND)panel->Handle.ToPointer() , panel->Width, panel->Height, 3, 3, 7 );
But this solution doesn't work properly. When i'm trying to initialize OpenGl machine
with this code (inside TCuboid construcor):
m_gHDC = GetDC( hwnd );
SetupPixelFormat();<br />
m_hRC = wglCreateContext( m_gHDC );
the variable: m_hRC is NULL and it shouldn't be.
I've tried my class code with other IDE and all was fine. So i think the problem is with getting panel's HWND.
Can somebody help me please?
-- modified at 9:52 Sunday 14th October, 2007
|
|
|
|
|
I have built a windows form using C#( .NET 2.0 ). The form has a label with text set to “:My label text.” When I build and run the form here everything looks fine.
When a person is running the form in UK he sees the label text as “.My label text:”
I am not able to figure out the reason for the colon to be moved to the end and the fullstop to be moved to the front.
I don’t think the UK locale(langauage and region) would be causing this.
Any pointers?
Thanks,
Sudhir
|
|
|
|
|
sudhirkamath wrote: I don’t think the UK locale(langauage and region) would be causing this.
Most likely could be the cause...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hello techs,
I have a small project which enables database backups.
I have to to do backup's for multiple database @ a time.
For that i need to use Threading concepts.
the below code is for database backup :
-----------------------------------------------------------------------------------------------------
public void backUpDatabase(string DBname, string setBakUpPath)
{
SqlCommand sCom = new SqlCommand("BACKUP DATABASE " + DBname + " TO DISK = '" + setBakUpPath + "' WITH NOFORMAT, NOINIT, NAME = 'Full Database1 Backup', SKIP, NOREWIND, NOUNLOAD,STATS = 10", sCon);
sCom.CommandType = CommandType.Text;
try
{
sCom.ExecuteNonQuery();
MessageBox.Show("Database " + DBname + " : BackUp Done!", DBname + " BackUp", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString(), "Backup ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
sCom.Dispose();
}
-----------------------------------------------------------------------------------------------------
all the databases will be loaded to a list box and i will select a database and clicks on button "Backup Database" and it will starts backup.... I need to do the backup in a thread. Now on the datagrid ... it will show the "db name", "Status : backup going on/backup done" and finally % of percentage of backup in the third colum of grid (u can avoid if this a bit time consuming... )
Please help me to solve it, if any clarifications needed... please ask ... thanks ...
A123-B321
|
|
|
|
|
I think db "backup time" depends on db size.
You can check your db backup thread status via standart c# event technick (read msdn for it)
|
|
|
|
|
Hi Guys and Gals.
I have a window form that has the autoscroll property set to true. This form needs the scroll bars. Now the problem is that I have a menu and a toolbar control. I want it to stay at the top even though I am scrolling to the bottom so that when someone is at the bottom of the screen they can still for instance click the save button without having to scroll all the way to the top.
Can someone please assist me to a solution?
Your help will be greatly appreciated.
Regards,
Elizma
|
|
|
|
|
Easy. Put your form's contents, except for the toolbars in a Panel control docked to the form and turn on it's autoscroll property.
|
|
|
|
|
Hi ,
I`ve implemented AppBars with help from the C# Does Shell-Part 3[^] article , but am having issues with the "Show Desktop" command .
What happens is that the AppBar itself gets minimized but upon restoration , its width becomes half of the earlier value. While debugging , i saw that the AppBar WndProc receives a FullScreenApp OS notification.
I`m handling this as :
if(lParam ==1 & appbar is topmost)
{ send it to bottom of z-order}
else if (lParam ==0 & appbar is bottom)
{ bring appbar to top of the z-order}
I need this logic so that my appbar is hidden when Word or IE enters full-screen mode & also to allow the user to see the start menu window.
Is there any other unique message that the OS sends to all active windows upon "Show Desktop" (other than WM_MINIMIZE) that i can handle ?
Any help or pointers are most appreciated.
Thanks in Advance
|
|
|
|
|
Hi,
I'm quite new to using VC++ and Windows forms. Although forms work well so far, I have an issue passing a handle from my main function to my form.
In main() I open a handle to a device. This handle must be available to my form so that when I click a button, it can use this handle to access my device and perform the intended action.
What is a good way to deal with this ?
regards
Marcel
recursive:
See "recursive"
|
|
|
|
|
I don't code C++, but as far as I know, the handle (or any other object) can only be accessed from inside the method they were defined in.
If you define the handle outside a method, it should be possible to access it everywhere.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
OK, I defined it as a global now and it works well.
It basically gets written to only one at startup of the application and only read in the rest of the application so this global may be the easiest way to deal with it.
Thanks,
Marcel
recursive:
See "recursive"
|
|
|
|
|
You can also pass the handle as an argument to the form's constructor, or create a (at least) writable property which you can pass the handle to. Either one would be neater than having the handle defined as static (global) variable.
|
|
|
|
|
hi,
I m writting an windows forms based application in C# and am facing an unusual problem..I have thrown an exception from a my business logic code but the execution control gets lost after I raise a business exception!
(The business logic code is in a seperate library project)
has this happened with someone? please help..
|
|
|
|
|
I think you're going to need to be a little clearer in the explanation of what's happening before any one will be able to help you.
alesh_nitre wrote: ..I have thrown an exception from a my business logic code
Is this a custom exception or one of the standard .NET exceptions? How are you throwing it?
alesh_nitre wrote: the execution control gets lost after I raise a business exception
This doesn't make sense to me. What do you mean "the execution control gets lost"?
|
|
|
|