Page 1 of 1
Form with console panel
Posted: Sun Jun 03, 2018 10:17 pm
by hmgchang
Dear Friends,
Is it possible to have a form with console panel inside ?
- Form with console panel inside
- DosInForm.JPG (25.9 KiB) Viewed 2047 times
TIA
best rgds,
Chang
Re: Form with console panel
Posted: Tue Jun 05, 2018 8:21 pm
by KDJ
Chang, you can try in this way:
Code: Select all
#include "hmg.ch"
REQUEST HB_GT_WIN_DEFAULT
MEMVAR _HMG_SYSDATA
FUNCTION Main()
DEFINE WINDOW MainForm;
WIDTH 700;
HEIGHT 500;
MAIN;
ON INIT MainFormOnInit();
ON PAINT RedrawWindow(GetConsoleWindow())
DEFINE BUTTON WriteButton
ROW 430
COL 10
WIDTH 130
HEIGHT 25
CAPTION "Write in console"
ACTION WriteInConsole()
END BUTTON
END WINDOW
MainForm.CENTER
MainForm.ACTIVATE
RETURN NIL
FUNCTION MainFormOnInit()
LOCAL nHWndConsole := GetConsoleWindow()
IF nHWndConsole != 0
IF SetParent(nHWndConsole, MainForm.HANDLE) != 0
SetMode(25, 80)
SetWindowPos(nHWndConsole, 0, 10, 10, 0, 0, 0x15 /*SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE*/)
RedrawWindow(nHWndConsole)
ENDIF
MainForm.WriteButton.SETFOCUS
? "0"
ENDIF
RETURN NIL
FUNCTION WriteInConsole()
STATIC n := 0
IF GetConsoleWindow() != 0
? HB_Ntos(++n)
ENDIF
RETURN NIL
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
HB_FUNC( GETCONSOLEWINDOW )
{
HMG_retnl((LONG_PTR) GetConsoleWindow());
}
#pragma ENDDUMP
Re: Form with console panel
Posted: Tue Jun 05, 2018 8:40 pm
by hmgchang
Thanks KDJ,
it works but it seem that I cannot activate/type the console as usual ?
Anyway to work around ? or can we have it function like a DOS Shell ?
TIA
best rgds,
Chang
Re: Form with console panel
Posted: Wed Jun 06, 2018 8:24 pm
by KDJ
Chang
I don't understand what console you need.
Do you mean command console (cmd)?
Re: Form with console panel
Posted: Wed Jun 06, 2018 9:32 pm
by hmgchang
Thanks KDJ,
my mistake.. I hv to code something to to console to work with....
Thanks again Sir...
best rgds,
Chang