Form with console panel

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Form with console panel

Post by hmgchang »

Dear Friends,

Is it possible to have a form with console panel inside ?
Form with console panel inside
Form with console panel inside
DosInForm.JPG (25.9 KiB) Viewed 2037 times
TIA

best rgds,
Chang
Just Hmg It !
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Form with console panel

Post 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
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Form with console panel

Post 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
Just Hmg It !
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Form with console panel

Post by KDJ »

Chang
I don't understand what console you need.
Do you mean command console (cmd)?
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Form with console panel

Post by hmgchang »

Thanks KDJ,
my mistake.. I hv to code something to to console to work with....

Thanks again Sir...

best rgds,
Chang
Just Hmg It !
Post Reply