Fafi
Lo he pasado a Harbour ( no utilizo XHarbour, aunque no creo que haya muchas diferencias )
Puedes probarlo de dos formas y modificarlo si lo necesitas
I've had to Harbour (do not use xHarbour, but do not think there are many differences)
You can try it in two ways and modify if needed
Code: Select all
#include "fivewin.ch"
Function Main()
Local nOp
//"What do you want", "Hello", "The correct answer is: YES", "You have not pressed"
MiWinMain( "Que quieres","Hola","La Respuesta correcta es: SI", "No has pulsado", 10000 )
Return nil
O directamente, y en este caso, puedes probar a eliminar la function MIWINMAIN y MWinMain
Or directly, and in this case, you can try to eliminate function MIWINMAIN and MWinMain
Code: Select all
#include "fivewin.ch"
Function Main()
Local nOp
//"If you do not press it close", "I've read?"
nOp := Timermensaje( "Si no pulsas lo cierro", "Lo has leido?", 10000 )
Do Case
Case nOp = 0
? "No has pulsado" //"You have not pressed"
Case nOp = 6
? "Has pulsado SI" //"You pressed YES"
Case nOp = 7
? "Has pulsado NO" //"You pressed NO"
EndCase
Return nil
Lo que no he probado es a cambiar los valores de retorno ( solo el 0 ), aunque creo que la solucion está en cambiar esas constantes aqui
What I have not tried is to change the return values (only 0), though I think the solution is to change these constants here
Code: Select all
PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
Code: Select all
//---------------------------------------------------------------------------//
#pragma BEGINDUMP
#define STRICT
#include <windows.h>
#include "hbapi.h"
/***********************************************************************
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright 1998 Microsoft Corporation. All Rights Reserved.
***********************************************************************/
/***********************************************************************
*
* MsgBox.c
*
* Abstract:
*
* Sample program to demonstrate how a program can display a
* timed message box.
*
***********************************************************************/
//#include <windows.h>
/***********************************************************************
*
* Overview
*
* The key to creating a timed message box is exiting the dialog
* box message loop internal to the message box. Because the
* message loop for a message box is part of USER, you cannot
* modify the message loop without using hooks and other such methods.
*
*
* However, all message loops exit when they receive a
* WM_QUIT message. Additionally, if a nested message loop
* receives a WM_QUIT message, the nested message loop must break
* the loop and then re-post the quit message so that the next
* outer layer can process it.
*
* Therefore, you can make the nested message loop exit by
* calling the PostQuitMessage function. The nested message loop will
* clean up and post a new quit message. When the MessageBox
* returns, you peek to see if there is a quit message. If so,
* it means that the message loop was abnormally terminated.
* You also consume the WM_QUIT message instead of re-posting it
* so that the application continues to run.
*
* Essentially, you have "tricked" the nested message loop into
* determining that the application is terminating. When the quit message
* returns, you consume the quit message. This method effectively cancels
* the fake quit message that you generated.
*
***********************************************************************/
/***********************************************************************
*
* Global variables
*
***********************************************************************/
HWND g_hwndTimedOwner;
BOOL g_bTimedOut;
/***********************************************************************
*
* MessageBoxTimer
*
* The timer callback function that posts the fake quit message.
* This function causes the message box to exit because the message box
* has determined that the application is exiting.
*
***********************************************************************/
void CALLBACK MessageBoxTimer(HWND hwnd,
UINT uiMsg,
UINT idEvent,
DWORD dwTime)
{
g_bTimedOut = TRUE;
if (g_hwndTimedOwner)
EnableWindow(g_hwndTimedOwner, TRUE);
PostQuitMessage(0);
}
/***********************************************************************
*
* TimedMessageBox
*
* The same as the standard MessageBox, except that TimedMessageBox
* also accepts a timeout. If the user does not respond within the
* specified timeout, the value 0 is returned instead of one of the
* ID* values.
*
***********************************************************************/
int TimedMessageBox(HWND hwndOwner,
LPCTSTR pszMessage,
LPCTSTR pszTitle,
UINT flags,
DWORD dwTimeout)
{
UINT idTimer;
int iResult;
g_hwndTimedOwner = NULL;
g_bTimedOut = FALSE;
if (hwndOwner && IsWindowEnabled(hwndOwner))
g_hwndTimedOwner = hwndOwner;
//
// Set a timer to dismiss the message box.
idTimer = SetTimer(NULL, 0, dwTimeout, (TIMERPROC)MessageBoxTimer);
iResult = MessageBox(hwndOwner, pszMessage, pszTitle, flags);
//
// Finished with the timer.
KillTimer(NULL, idTimer);
//
// See if there is a WM_QUIT message in the queue if we timed out.
// Eat the message so we do not quit the whole application.
if (g_bTimedOut)
{
MSG msg;
PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
iResult = 0; //-1;
}
return iResult;
}
/***********************************************************************
*
* WinMain
*
* Program entry point. Demonstrate TimedMessageBox().
*
***********************************************************************/
int WINAPI MWinMain(HINSTANCE hinst,
HINSTANCE hinstPrev,
LPSTR pszCmdLine,
int nCmdShow,
LPCTSTR pszMessage,
LPCTSTR pszTitle,
LPCTSTR pszMensaje,
LPCTSTR pszTitMensaje,
DWORD dwTimeout )
{
UINT uiResult;
//
// Ask the user a question. Give the user five seconds to
// answer the question.
uiResult = TimedMessageBox(NULL,
pszMessage, //"Does a triangle have three sides?",
pszTitle, //"Quiz",
MB_YESNO,
// NULL first parameter is important.
dwTimeout ); //5000);
switch (uiResult) {
case IDYES:
MessageBox(NULL,
"That's right!",
"Result",
MB_OK);
break;
case IDNO:
MessageBox(NULL,
"Believe it or not, triangles "
"really do have three sides.",
"Result",
MB_OK);
break;
case -1:
MessageBox(NULL,
pszMensaje,
pszTitMensaje,
MB_OK );
/*
"I sensed some hesitation there. "
"The correct answer is Yes.",
"Result",
MB_OK);
*/
break;
}
return 0;
}
//---------------------------------------------------------------------------//
HB_FUNC( MIWINMAIN ) //
{
MWinMain( ( HINSTANCE ) hb_parnl( 6 ), ( HINSTANCE ) hb_parnl( 7 ),
( LPSTR ) hb_parnl( 8 ), hb_parnl( 9 ),
hb_parc( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parc( 4 ),
hb_parnl( 5 ) );
}
//---------------------------------------------------------------------------//
HB_FUNC( TIMERMENSAJE )
{
UINT uiResult;
uiResult = TimedMessageBox(NULL,
hb_parc( 1 ), //pszMessage, //"Does a triangle have three sides?",
hb_parc( 2 ), //pszTitle, //"Quiz",
MB_YESNO,
// NULL first parameter is important.
hb_parnl( 3 ) ); //dwTimeout ); //5000);
hb_retnl( uiResult );
}
//---------------------------------------------------------------------------//
#pragma ENDDUMP