MsgInfo()

424 views
Skip to first unread message

Qatan

unread,
Mar 6, 2011, 1:16:29 PM3/6/11
to harbou...@googlegroups.com
Hello,
 
    I am not sure it is possible but I would like to port a little C program to use from inside Harbour.
    Unfortunatelly my C knowledge is no much beyond 0...
    Plese look the following pure C code (to test run it: gcc -otest.exe -mwindows test.c):
   
[code]
#include <windows.h>
 
int WINAPI WinMain( HINSTANCE hInstance,   HINSTANCE hPrevInstance, LPSTR lpCmdLine,   int
 
nCmdShow )
{
   MessageBox( 0, "Hello World!", "From Harbour", MB_ICONINFORMATION );
  
   return 0;
}
[/code]
 
 
    Than I tried to do something like the following "catastrofic" code that obviously didnt work at all:
 
 
[code]

proc main()
  msginfo( 'From Harbour', 'Hello World!' )
retu
 
//////////////////////////////////////////////
#pragma begindump
 
#include <windows.h>
 
HB_FUNC( MSGINFO )
 
{
  hb_retnl( 0 );
 
   PHB_ITEM pTitle = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pMessage = hb_param( 2, HB_IT_STRING );
 
      int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
         {
               MessageBox( 0, hb_param( 2, HB_IT_STRING ), hb_param( 1, HB_IT_STRING ), MB_ICONINFORMATION );
 

          }
 
    hb_retc_null();
}
#pragma enddump
[/code]
 
 
    Is it possible to have something like that? I just want to be able to create a little message on the screen
    Any hint is welcome.
   
Qatan

Vailton Renato

unread,
Mar 6, 2011, 7:59:09 PM3/6/11
to harbou...@googlegroups.com
Hi Qatan!

Try this:

/*
* An MsgInfo() implementation using hbwin library.
* 06/03/2011 - 21:56:45
*
* COMPILE: hbmk2 msginfo1.prg -run -lhbwin
*/
#include "hbwin.ch"

FUNCTION MAIN()
? MsgInfo( "This is a single test" )
RETURN nil

FUNCTION MSGINFO( cText, cTitle )
RETURN WAPI_MESSAGEBOX( 0, cText, cTitle, WIN_MB_ICONQUESTION )

Regards,
Vailton Renato

2011/3/6 Qatan <wanst...@gmail.com>:

> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users
>

Qatan

unread,
Mar 6, 2011, 10:27:30 PM3/6/11
to harbou...@googlegroups.com
Hello Vailton,

It works well.
I was "reinventing the wheel"! I should search more before thinking I
will have to do "invent" something. It was there all this time and I didn�t
see it...
Well your example works but creates a console window in the back of the
message.
To avoid that I tried to add these lines:
announce HB_GTSYS
request HB_GT_NUL
And compile with -GUI flag (using HBMK2). With that the console window
does not appear and I found the solution for my needs.
Anyway, follows my "reinvention" extracted from a mix of information
from different foruns, help from Culik of xHarbour and from GTWVW sources
(after some brief study).

[CODE]
/*
* MyMsg.ch
*/
#define MB_OK 0
#define MB_OKCANCEL 1
#define MB_ABORTRETRYIGNORE 2
#define MB_YESNOCANCEL 3
#define MB_YESNO 4
#define MB_RETRYCANCEL 5
#define MB_CANCELTRYCONTINUE 6

#define MB_ICONERROR 16
#define MB_ICONQUESTION 32
#define MB_ICONEXCLAMATION 48
#define MB_ICONINFORMATION 64
#define MB_USERICON 128

#define MB_APPLMODAL 0
#define MB_SYSTEMMODAL 4096
#define MB_TASKMODAL 8192
#define MB_HELP 16384 // Help Button

#define MB_NOFOCUS 32768
#define MB_SETFOREGROUND 65536
#define MB_DEFAULT_DESKTOP_ONLY 131072

#define MB_TOPMOST 262144
#define MB_RIGHT 524288
#define MB_RTLREADING 1048576

#define IDOK 1
#define IDCANCEL 2
#define IDABORT 3
#define IDRETRY 4
#define IDIGNORE 5
#define IDYES 6
#define IDNO 7
#define IDCLOSE 8
#define IDHELP 9
#define IDTRYAGAIN 10
#define IDCONTINUE 11

/*
* Test.prg
*/
announce HB_GTSYS
request HB_GT_NUL

proc main()
MyMsg( 'Titulo','Hello World!', MB_TOPMOST + MB_SETFOREGROUND )
MyMsg( 'Titulo','Hello World!', MB_ICONERROR + MB_SETFOREGROUND )
MyMsg( 'Titulo','Hello World!', MB_ICONQUESTION +
_DEFAULT_DESKTOP_ONLY )
MyMsg( 'Titulo','Hello World!', MB_ICONEXCLAMATION + MB_HELP +
MB_DEFAULT_DESKTOP_ONLY )
MyMsg( 'Titulo','Hello World!', MB_ICONINFORMATION + MB_NOFOCUS +
MB_DEFAULT_DESKTOP_ONLY )
retu

#PRAGMA BEGINDUMP

#include <windows.h>
#include "hbapi.h"
HB_FUNC( MYMSG )
{
hb_retni( MessageBox( NULL, hb_parcx( 2 ), hb_parcx( 1 ), ISNIL( 3 ) ?
MB_OK : hb_parni( 3 ) ) ) ;
}
#PRAGMA ENDDUMP

[/CODE]

Well, learning day-by-day...

Qatan

Chee Chong Hwa

unread,
Mar 6, 2011, 11:32:29 PM3/6/11
to harbou...@googlegroups.com
Hi Qatan

Why reinvent the wheel ?

There is already a MsgInfo() and MsgYesNo() functions available in the HMG/Minugui libs.

If you are looking to guify ALERT(), Pritpal Bedi has such a function in gtWVG lib.I think there is also a wAlert() function available as a contribution in the HMGExtended forum

Cheers

http://cch4clipper.blogspot.com



--

Qatan

unread,
Mar 7, 2011, 7:04:38 AM3/7/11
to harbou...@googlegroups.com
Hello Chee,
 
    You are right. I was "reinventing the wheel..."  
    I just got a message from Vailton with the solution. It was there all the time and I didn´t notice.
    Seems that Harbour has much more to offer than what I thought.
    Regards,
 
Qatan

Chee Chong Hwa

unread,
Mar 7, 2011, 7:17:12 AM3/7/11
to harbou...@googlegroups.com
Hi Qatan

Yeah, Harbour 2.1 is actually very rich but the lack of documentation on newer functions, syntax is pretty frustrating.
Anyway, I am looking into the possibility of writing a series of articles on wapi and how it could be used in Harbour.

For a start, I have made Vailton solution into an article as folllows :-

http://cch4clipper.blogspot.com/2011/03/adding-msginfo-functionality-to-harbour.html

Cheers
CCH

Qatan

unread,
Mar 7, 2011, 7:39:38 AM3/7/11
to harbou...@googlegroups.com
Hello Chee,
 
    Nice. Please, just fix Vailton's name there because it is not right.
    There it says "Vailthon"

Chee Chong Hwa

unread,
Mar 7, 2011, 11:48:32 PM3/7/11
to harbou...@googlegroups.com
Hi Qatan

Done :-)

Gab

unread,
Oct 14, 2016, 8:43:23 AM10/14/16
to Harbour Users
Hi,

Is it possible to add clickable hyperlink in a messagebox?

thx

Hazael

unread,
Nov 1, 2016, 5:24:13 AM11/1/16
to Harbour Users
Hi Gab,

I fear it is not possible... unless someone develops a special messagebox that has such feature.
Give a look here: http://www.codeproject.com/Articles/9579/CPPMessageBox-v1-0

Hope it helps

Qatan

Gab

unread,
Nov 2, 2016, 3:46:09 AM11/2/16
to Harbour Users
Hi Qatan,

I suspected that something similar like this, but thanks for yor answer.

Gab
Reply all
Reply to author
Forward
0 new messages