NO

Author Topic: MessageBox or Form with Question and TimeOut  (Read 7010 times)

ml1969

  • Guest
MessageBox or Form with Question and TimeOut
« on: June 01, 2009, 10:49:25 AM »
Hi,

it´s me again  ;D.

So I have a new Problem.

The easiest way would be a MessageBox with TimeOut, but all the solutions I found base on the import of user32.dll  and that won´t work on a PNA (winCe)  >:(.
The Problem itself is quiet easy.

The Program should bring automaticaly the PNA in suspend-mode, if the powercord is taken away....

All this works.

If I detect that the external power is down I will ask the User if its correkt to shut down.
The user has the option to cancel, or if 5 seconds nothing happens it shoud do automatically.

The normal MessageBox will wait on an input of an user,
if I take a normal form (createwindow) I cant brak the messageloop  >:(

I also tried SetTimer, but nothings happend....

Do someone knows a solution?


Michael

JohnF

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #1 on: June 01, 2009, 10:56:46 PM »
=============
The normal MessageBox will wait on an input of an user,
if I take a normal form (createwindow) I cant brak the messageloop
=============

If you user clicks ok, do whatever is required. If the user click cancel do whatever is required. Simple. If your app should exit call PostQuitMessage(), if not carry on.

John

ml1969

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #2 on: June 01, 2009, 11:12:50 PM »
Hello,

I understand what you mean, but my problem is...

I create a form,  e.g. with yes and cancel button, if the user clicks all is ok.

But I want to close the form after (lets say) 5 seconds in case the is NO userclick and carry on like the user clicked yes...

Michael




JohnF

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #3 on: June 02, 2009, 07:55:30 AM »
Use SetTimer, after five seconds if the user has not responded close the window.

DestroyWindow(hwnd);

John

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: MessageBox or Form with Question and TimeOut
« Reply #4 on: June 04, 2009, 08:22:35 AM »
But I want to close the form after (lets say) 5 seconds in case the is NO userclick and carry on like the user clicked yes...

Michael

Hi,

in the attachment you will find a very little dialogbase timer-application. Maybe it helps you.  ;)
best regards
 Alex ;)

ml1969

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #5 on: June 05, 2009, 09:44:32 PM »
Hi,

nice work dor an non WinCe-machine with ARM-Processor.

But i dont get it running for my PNA (ARM WinCe)  >:(

I Want to realize a app, which turn the PNA in SUSPEND-mode when the power cord is put out ...

This is my basic code... it works, but I what I want is a "timeout" function.
If no Button was clicked, the PNA should go in SuspendMode..
Code: [Select]
#include <windows.h>
#include <windowsx.h>

#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include <winioctl.h>
#include <string.h>
#include <winioctl.h>


#define POWER_STATE_RESET (DWORD)(0x00800000)
#define POWER_STATE_SUSPEND (DWORD)(0x00200000)
#include "main.h"


DWORD SetSystemPowerState(  LPCWSTR psState,  DWORD StateFlags,  DWORD Options);

int reset(void);
BOOL run = FALSE;

 SYSTEM_POWER_STATUS_EX sps;



int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{

   while (run == FALSE)
    {
GetSystemPowerStatusEx(&sps, TRUE) ;

if (sps.ACLineStatus == AC_LINE_OFFLINE )
{
reset();
}
_sleep(1);
    }

return 0;
}



int reset(VOID)
{
GetSystemPowerStatusEx(&sps, TRUE) ;

if (sps.ACLineStatus == AC_LINE_OFFLINE )
{

if (MessageBox(NULL, L"PNA schaltet sich in 4 Sekunden ab!" , L"ACHTUNG", MB_ICONWARNING | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_YESNO) == IDYES)
{

SetSystemPowerState (NULL, POWER_STATE_SUSPEND ,0 );
}
else
{


}
_sleep(4);
while (sps.ACLineStatus == AC_LINE_OFFLINE)
{
GetSystemPowerStatusEx(&sps, TRUE) ;
_sleep(1);
}

return 0;
}


Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: MessageBox or Form with Question and TimeOut
« Reply #6 on: June 06, 2009, 04:36:14 PM »
Hi,

nice work dor an non WinCe-machine with ARM-Processor.


Na gut, dann für den Pocket PC  :)
What means:
Also well, then for the Pocket PC  :)

EDIT: Attachment new ;)
« Last Edit: June 06, 2009, 04:48:13 PM by AlexN »
best regards
 Alex ;)

ml1969

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #7 on: June 06, 2009, 04:56:46 PM »
Ohh you speak german  ;D

gut zu wissen, vereinfacht die Lage ungemein  (good to know :-) )

Wer ich mir gleich mal anschauen..... steh da als newbie grad vollkommen aufm Schaluch

Was mir gleich auffällt ist die aygshell.dll die gibt es leider auf dem PNA nicht.

Danke erstmal

Michael


Hi,

nice work dor an non WinCe-machine with ARM-Processor.


Na gut, dann für den Pocket PC  :)
What means:
Also well, then for the Pocket PC  :)

EDIT: Attachment new ;)
« Last Edit: June 06, 2009, 05:00:01 PM by ml1969 »

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: MessageBox or Form with Question and TimeOut
« Reply #8 on: June 06, 2009, 08:51:02 PM »
gut zu wissen, vereinfacht die Lage ungemein  (good to know :-) )
Yes, but we are on a english forum and I also don't like when people write in an english forum russia, italian, spain or something else. If you want speak (write) german to me send personal messages.

Maybe Christian spend a german group for this forum (because we it is the forum of a german web-site and he had a long time before a german forum).

To your problem I only produced with the wizard a dialog based project and added the timer and your code and tested it on me Pocket PC.
« Last Edit: June 06, 2009, 10:08:54 PM by AlexN »
best regards
 Alex ;)

ml1969

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #9 on: June 07, 2009, 10:03:11 AM »
HelloAlex,

make sens  ;D, .......
(I think you also use 6.0 BETA??) 
But this is no problem, and I also tried the way with the wizzard, but the missing aygshell on most PNAs deny that.

The basic code I posted works fine, only the messagebox should be changed in a form...
At this time I try something with the Modeless Dialog Box..... perhaps this will help me.


Michael

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: MessageBox or Form with Question and TimeOut
« Reply #10 on: June 07, 2009, 04:05:56 PM »
(I think you also use 6.0 BETA??) 
But this is no problem, and I also tried the way with the wizzard, but the missing aygshell on most PNAs deny that.

Yes, I use Pelles C 6.0RC2

The basic code I posted works fine, only the messagebox should be changed in a form...
At this time I try something with the Modeless Dialog Box..... perhaps this will help me.


The program I send you, I test with the start function of Pelles C on my Pocket PC (an ASUS myPal 696 with Windows Mobile 6).
I got a dialogbox with a button and a text counting down to suspend mode. There was no question for an agshell.dll or something else.
best regards
 Alex ;)

ml1969

  • Guest
Re: MessageBox or Form with Question and TimeOut
« Reply #11 on: June 08, 2009, 05:49:27 AM »

The program I send you, I test with the start function of Pelles C on my Pocket PC (an ASUS myPal 696 with Windows Mobile 6).
I got a dialogbox with a button and a text counting down to suspend mode. There was no question for an agshell.dll or something else.

Sure, I thought if I tell you, that is for an PNA  not PDA that would be enough.

The Code non_ppc works fine on a XP-machine the ppc_code works fine on my PDA  :D, but the most PNA have a limited WinCE without....
OK, i tried it out working without the aygshell.dell  ;) but..I will learning more abot dialogboxes, the way with a modeless dialogbox should also work?

Michael

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: MessageBox or Form with Question and TimeOut
« Reply #12 on: June 08, 2009, 08:23:33 AM »
[Sure, I thought if I tell you, that is for an PNA  not PDA that would be enough.

Reading is hard thing, if there stand something other then you expect.  ;)

Maybe you can make a window based application with the text in the middle. I have have no PNA to test something.  :(
best regards
 Alex ;)