It is currently Thu Dec 13, 2018 2:37 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Positioning DOS window
PostPosted: Wed Jun 27, 2018 2:13 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Dec 21, 2015 8:12 pm
Posts: 133
You need the "_" prefix for x86.

Code:
Import "kernel32.lib"
  CompilerIf#PB_Compiler_Processor = #PB_Processor_x86
    GetConsoleWindow_() As "_GetConsoleWindow"
  CompilerElse
    GetConsoleWindow_() As "GetConsoleWindow"
  CompilerEndIf
EndImport


Top
 Profile  
Reply with quote  
 Post subject: Re: Positioning DOS window
PostPosted: Wed Jun 27, 2018 3:32 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4339
Location: Lyon - France
@Mijikai
Me too i have Polink error :|
W7 X86 / v5.61(X86)

Fryquez wrote:
You need the "_" prefix for x86.
Even with your code FRYQUEZ, i have a polink error :|

Code:
Import "kernel32.lib"
  CompilerIf#PB_Compiler_Processor = #PB_Processor_x86
    GetConsoleWindow_() As "_GetConsoleWindow"
  CompilerElse
    GetConsoleWindow_() As "GetConsoleWindow"
  CompilerEndIf
EndImport

Procedure.i SetConsolePosition(X.i,Y.i)
  ProcedureReturn SetWindowPos_(GetConsoleWindow_(),#Null,X,Y,#Null,#Null,#SWP_NOZORDER|#SWP_NOSIZE|#SWP_SHOWWINDOW)
EndProcedure

Procedure.i SetConsolePosition_XP(X.i,Y.i)
  Protected WindowHandle.i
  Protected Buffer.s = Space(1024)
  If GetConsoleTitle_(@Buffer,1024)
    WindowHandle = FindWindow_(#Null,Buffer)
    If WindowHandle
      ProcedureReturn SetWindowPos_(WindowHandle,#Null,X,Y,#Null,#Null,#SWP_NOZORDER|#SWP_NOSIZE|#SWP_SHOWWINDOW)
    EndIf
  EndIf
EndProcedure

If OpenConsole()
  SetConsolePosition(10,10)
  ;SetConsolePosition_XP(10,10)
  Input()
EndIf

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: Positioning DOS window
PostPosted: Wed Jun 27, 2018 3:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Dec 21, 2015 8:12 pm
Posts: 133
Hmm, guess I don't have the default lib.
Can you try "_GetConsoleWindow@0"?


Top
 Profile  
Reply with quote  
 Post subject: Re: Positioning DOS window
PostPosted: Thu Jun 28, 2018 1:34 am 
Offline
New User
New User
User avatar

Joined: Wed Jun 27, 2018 5:12 am
Posts: 8
Another way... Since it is newly created, the OS will put our console on foreground.
The GetForegroundWindow_() can then be used at the beginning of the code to get the appropriate handle.

Code:
If OpenConsole()

  ;Set console position
  SetWindowPos_(GetForegroundWindow_(), #HWND_TOP, 150, 150, #Null, #Null, #SWP_NOZORDER|#SWP_NOSIZE|#SWP_SHOWWINDOW)
  PrintN("Console is at position 150, 150.")
  Sleep_(1500) 

  ;Center console
  Define.rect ConsoleRect : GetWindowRect_(GetForegroundWindow_(), ConsoleRect)
  SetWindowPos_(GetForegroundWindow_(), #HWND_TOP,
  (GetSystemMetrics_(#SM_CXSCREEN) - (ConsoleRect\Right  - ConsoleRect\Left)) / 2,
  (GetSystemMetrics_(#SM_CYSCREEN) - (ConsoleRect\Bottom - ConsoleRect\Top)) / 2,
  #Null, #Null, #SWP_NOZORDER | #SWP_NOSIZE | #SWP_SHOWWINDOW)
  PrintN("Console is now centered on screen.")

  Input() : CloseConsole()

EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: Positioning DOS window
PostPosted: Thu Jun 28, 2018 2:24 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4339
Location: Lyon - France
@Pierre Bellisle
That's works very well, thanks 8)

fryquez wrote:
Hmm, guess I don't have the default lib.
Can you try "_GetConsoleWindow@0"?
You are too strong :shock:
That works now 8)
Thanks at MIJIKAI and you :wink:

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye