Quickwin to Console Conversion

Quickwin to Console Conversion

Hi,

I need some help on converting a quickwin to a console application. More specifically, when I run the exe it would read some input files and generate some output text files and bitmap files. In my quick win application, this works but the quickwin window flashes up momentarily and I exit the application with SETEXITQQ(QWIN$EXITNOPERSIST). What I need is not to have the quickwin window show up even momentarily. I thought converting that to a console application. Would that be the way to go. Am I correct? Please help
Secondly, after I setup my console app, I get linker 2001 errors unresolved external symbol __initializefonts

and
LNK2001: unresolved external symbol __f_setfont@8
Now, I want to output the graphics into a file (not for display). Are calls to initializefonts and setfont quickwin specific and is that my problem.
Thanks for any help.

Regards,

Sumit

10 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Actually, the best way to go would be to convert it to a Windows application. Don't be affraid -- all it needs is to have a WinMain() instead of PROGRAM statement; it does not need to have any windows nor the message loop.

However, since apparently it also requires some drawing capabilities, you cannot use QuickWin functions -- they require QuickWin windows. You may try to use ShowWindow(SW_HIDE) on the program start, but I think it would cause a flash.

I'd recommend investigating porting to my XFTGDI module. It's significantly simpler than Windows API, and it's able to draw onto buffers (without windows). I think I replied here to a similar request before -- see here.

Jugoslav

Jugoslav www.xeffort.com

Thank you for your reply. I will try to get into WinMain ?%??#! (I am a chemical engineer with very basic programming skills). However, in the meantime I tried the libs:/qwins option instead of qwin and that does a does a flash screen momentarily and without the menus . But my more immediate requirement is how do I save a bitmap without displaying it on Screen.

The sequence of quickwin functions are

 Subroutine SCINIT_I
      USE DFLIB
      LOGICAL              statusmode
      TYPE (windowconfig)  myscreen
      COMMON               myscreen
  .
  CALL CLEARSCREEN($GCLEARSCREEN)
  open (5,File='user',Title='PTI-GRAPHICS')
      myscreen.numxpixels  = -1
      myscreen.numypixels  = -1
      myscreen.numtextcols = -1
      myscreen.numtextrows = -1
      myscreen.numcolors   = -1
      myscreen.fontsize    = -1
      myscreen.title       = ""C
      statusmode = SETWINDOWCONFIG(myscreen)
      IF(.NOT. statusmode) statusmode = SETWINDOWCONFIG(myscreen)
      statusmode = GETWINDOWCONFIG( myscreen )
 
      END SUBROUTINE SCINIT_I  
!**************************************
Subroutine Draw
....
CALL SCINIT_I
numfonts_a = INITIALIZEFONTS ( )
fontnum_a = SETFONT ('t''Arial''h14w10i')
 CALL SCRDEF_I(0., 0., 10., 7.5)
  CALL VIEWPT_I(.6, 0.2, 9.5, 7.2)
CALL SCRLMTS_I(XL,YL,XU,YU) 
...
!Draw lines and arcs with Lineto_W ,Moveto_W, SetCOLORRGB, SETLINESTYLE,OUTGTEXT etc
....
  status=saveimage_w("picture.bmp",XL,YU,XU,YL)
close(5)
End Subroutine Draw

Now creating that picture.bmp is very important for my application without actually showing it on screen.
Can you please tellme how to do that or what call actually displays the image to the screen.

Thanks for any help.

PS. The requirement for this is that a C Sharp program (not written by me or anyone in my firm, so I do not have source etc) will run the executeable (read files and generate files) and use the outputfiles to generate a web based interface. I have been told that the C# program cannot handle the generation of a window momentarily also. I have been told to modify my application to a C++ console type application (something like running a dos command)
Thanks again!

A Win32 application does not create any windows; a console application must have a console window. One or another may suit your needs. In any case, converting to one or another is a 5-minute job.

A more serious problem is that you can't use QuickWin routines anymore. QuickWin creates a frame window always, and child windows are created on any graphic operation. I recommend porting it to XFTGDI. Here's a brief sample how to create and save a bitmap with it:

INTEGER FUNCTION WinMain(hi, hpi, lpsz, nshow)
!DEC$ATTRIBUTES STDCALL, ALIAS: "_WinMain@16":: WinMain
USE DFWIN
USE XFTGDI
INTEGER:: hi, hpi, lpsz, nshow, iSt
TYPE(X_DC):: xDC
TYPE(X_BITMAP):: xBmp

xDC = XMemoryDC(800,600)
CALL XSetViewport(xDC, 0, 0, 799, 599)
CALL XSetWindow(xDC, 0., 0., 400., 300.)
CALL XSetPen(xDC, XRGB(255,0,0))
CALL XSetBrush(xDC, XRGB(255,255,255))
iSt = XSetFont_W(xDC, "Arial", 14., fWidth=10.)


iSt = XRectangle_W(xDC, 0., 0., 400., 300.)


CALL XSetBrush(xDC, XRGB(0,0,255))
iSt = XRectangle_W(xDC, 20., 20., 380., 200.)
iSt = XTextOut_W(xDC, 200., 210., "A Sample", XRGB(0,128,0), iStyle=TA_CENTER)


IF (XGetBitmap_W(xDC, xBmp, 0., 0., 400., 300.)) THEN
   iSt = XSaveBitmap(xBmp, "picture.bmp", 24)
END IF
WinMain = 0


END FUNCTION WinMain

I hope the logic of the code is clear.

Jugoslav

P.S. Due to a CVF's half-bug, you may get a stack overflow in XSaveBitmap. If that's the case, delete the text (1:BI%bmiHeader%biSizeImage) from the offending line.

Jugoslav www.xeffort.com

Thank you very much!
I will work on it.
Rgds

Dear Jugoslav,

One error I get while compiling XFTGD1 is the following

C:winappXftGDI.f90(1632) : Error: The type of the actual argument differs from the type of the dummy argument.   [BI]

iSt = GetDIBits(hdcComp, xBmp%hBmp, 0, BI%bmiHeader%biHeight, LOC(bmBits), BI, DIB_RGB_COLORS)

where
TYPE(T_BITMAPINFO):: BI ; POINTER(pBI, BI)

I have been able to comment that statement (starting with isT) out and compile
XFTLITE and it works.

So in my new test application
I added the above WinMain Code in main.f90 and added XFTGDI.f90 and compiled and it runs without creating any windows. However, the file picture.bmp is not created in any directory (I was thinking itwill be a bitmap file with the statement in outtext in it). I must be doing something wrong.
Thanks in advance for any help.

You commented out the crucial line. That line should read:

iSt = GetDIBits(hdcComp, xBmp%hBmp, 0, BI%bmiHeader%biHeight, LOC(bmBits), LOC(BI), DIB_RGB_COLORS)

Without it, XSaveBitmap fails.

Sorry for inconvenience, the version on the site was created with CVF 5.0. I try to maintain the code to be compilable under all versions, but sometimes (euphemism for "usually") I lose track what's in which project, what's on the web and so on... I'll fix the version on the site soon.

Jugoslav www.xeffort.com

Thanks Jugoslav,

I probably need some more help.
I changed XFTGDI code from BI to LOC(BI) and it now compiles without any error.

Now about the winmain sample above, when compiled with XFTGDI creates picture.bmp of 1kb size. However, when I open it in paintbrush, I do not see text or anything in it. I tried changing RGB values incase background value same a pen color. Did not help. I tried adding line
lret= XLine_W(xDC, 40., 40.,200.,200.)
but does not show in bitmap.
Can you please guide me as to what I am doing wrong.
Thanks again

Hmmmm... I'm running out of ideas. I uploaded a new version to my site this morning -- try re-downloading it.

Jugoslav www.xeffort.com

Thanks Jugoslav,

It is working in my home computer. The new downloaded version and makes a 1.37MB bitmap file with the window and text.

I will work on the conversion from here on.

Thanks again for all your help but will bug you some more probably.

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi