Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: I need help with C# loops Pin
Guffa21-Jan-08 22:19
Guffa21-Jan-08 22:19 
GeneralRe: I need help with C# loops Pin
PIEBALDconsult22-Jan-08 6:39
mvePIEBALDconsult22-Jan-08 6:39 
GeneralRe: I need help with C# loops Pin
Guffa22-Jan-08 9:02
Guffa22-Jan-08 9:02 
GeneralRe: I need help with C# loops Pin
Gareth H21-Jan-08 11:38
Gareth H21-Jan-08 11:38 
GeneralRe: I need help with C# loops Pin
Guffa21-Jan-08 13:20
Guffa21-Jan-08 13:20 
GeneralRe: I need help with C# loops Pin
PIEBALDconsult21-Jan-08 16:19
mvePIEBALDconsult21-Jan-08 16:19 
JokeRe: I need help with C# loops Pin
Guffa21-Jan-08 22:01
Guffa21-Jan-08 22:01 
GeneralPostMessage Problem Pin
stebo072821-Jan-08 9:02
stebo072821-Jan-08 9:02 
Ok, here is good question. I am building an application, which has a mainform, that opens a splash screen, shows a load progress bar, then jumps to the system tray. All of that is working fine. Now I am trying to implement some code that will allow me to insure that only one instance will open. I have done this successfully using a Mutex module and its WaitOne function. Now when the WaitOne function fails, i catch it with an else clause, which works, debugging shows it caught correctly, now I want to somehow tell the already open instance that someone tried to open you again, and to pop up a message balloon saying here i am. I have the following code, which sends a system message using PostMessage, and I have overridden the WndProc procedure in the MainForm, but the WndProc does not catch the message. I cannot figure out why. I know that the WndProc catches messages, because I tested it by inserting a thumbdrive, and the WM_DEVICECHANGED message was caught, but my custom message is no caught which leads me to beleive there is a problem with PostMessage, anyway here is my code

Mutex mutex = new Mutex(true, "MyProgram");

[STAThread]
static void Main()
{
if(mutex.WaitOne(TimeSpan.Zero, true))
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
mutex.ReleaseMutex();
}
else
{
NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST,
NativeMethods.ALREADYOPEN, IntPtr.Zero, IntPtr.Zero);
}
}

In the NativeMethods, HWND_BROADCAST is defined as 0xffff and the ALREADYOPEN message is defined with RegisterWindowsMessage("ALREADYOPEN")

then in the MainForm i have the following code

protected override void WndProc(ref Message m)
{
if(m.Msg == NativeMethods.ALREADYOPEN)
{
here is the code to show the BalloonToolTip, but this is never reached
}
base.WndProc(ref m);
}

In debug I can watch all the original creation messages being caught, and like I said the WM_DEVICECHANGED message is caught when I insert a thumb drive, but for some reason my custom message is not being caught, something has to be wrong in the PostMessage area I am thinking

Can anyone shed any light here?
GeneralRe: PostMessage Problem Pin
stebo072821-Jan-08 10:40
stebo072821-Jan-08 10:40 
GeneralForm diagram Pin
netJP12L21-Jan-08 5:31
netJP12L21-Jan-08 5:31 
GeneralRe: Form diagram Pin
Gareth H21-Jan-08 8:09
Gareth H21-Jan-08 8:09 
GeneralRegarding Google language translation C# Pin
Member 470816321-Jan-08 4:48
Member 470816321-Jan-08 4:48 
Generalproblem with value from database Pin
eyeseetee21-Jan-08 4:31
eyeseetee21-Jan-08 4:31 
AnswerRe: problem with value from database Pin
Vikram A Punathambekar21-Jan-08 5:02
Vikram A Punathambekar21-Jan-08 5:02 
GeneralRe: problem with value from database Pin
Gareth H21-Jan-08 8:04
Gareth H21-Jan-08 8:04 
Generalradiobutton list enable one of the items Pin
eyeseetee21-Jan-08 3:31
eyeseetee21-Jan-08 3:31 
GeneralRe: radiobutton list enable one of the items Pin
Mustafa Ismail Mustafa21-Jan-08 3:36
Mustafa Ismail Mustafa21-Jan-08 3:36 
GeneralRe: radiobutton list enable one of the items Pin
eyeseetee21-Jan-08 3:48
eyeseetee21-Jan-08 3:48 
GeneralRe: radiobutton list enable one of the items Pin
eyeseetee21-Jan-08 3:56
eyeseetee21-Jan-08 3:56 
GeneralRe: radiobutton list enable one of the items Pin
Mustafa Ismail Mustafa21-Jan-08 3:59
Mustafa Ismail Mustafa21-Jan-08 3:59 
GeneralRe: radiobutton list enable one of the items Pin
eyeseetee21-Jan-08 4:05
eyeseetee21-Jan-08 4:05 
GeneralRe: radiobutton list enable one of the items Pin
Skippums21-Jan-08 7:04
Skippums21-Jan-08 7:04 
QuestionHow to overwrite datas in the storage?? Pin
peaceziz21-Jan-08 3:27
peaceziz21-Jan-08 3:27 
AnswerRe: How to overwrite datas in the storage?? Pin
Mustafa Ismail Mustafa21-Jan-08 3:33
Mustafa Ismail Mustafa21-Jan-08 3:33 
Questionhow to use the keyword 'LIKE' in SQL query in C# code, what will be the sentax of C# statement Pin
mavii21-Jan-08 2:32
mavii21-Jan-08 2:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.