|
Post by bigbrix on Oct 21, 2020 9:32:16 GMT -5
Hello Everybody, my first post/plea for help.
I am creating a program that has a "splash screen", which after a prompt changes the image and then runs another program in a window on the graphic screen. After a lot of research, I have been unable to find out how to position the program window on the graphic screen. Would be very grateful for some help. Cheers Bigbrix
|
|
|
Post by Rod on Oct 21, 2020 10:59:25 GMT -5
Post your code, we don’t need the images but we do need to understand what you are coding.
|
|
|
Post by bigbrix on Oct 21, 2020 11:33:34 GMT -5
Hello, Thanks for the reply, I hope you appreciate that this is an on going project and the code is probably a horror to you. It does run, though I have not supplied the whole of the program I want to run, but it shows what I want. The window is not centred in a decent position within the graphic. probably a simple matter for the experts, but...... Cheers Brian
nomainwin WindowWidth = 1370 WindowHeight = 768
UpperLeftX = int((DisplayWidth - WindowWidth)/2) UpperLeftY = int((DisplayHeight - WindowHeight)/2) file$ = "c:\Bantam\Bantam_project\Bigbant.jpg"
open "jpeg.dll" for DLL as #j calldll #j, "LoadImageFile",_ hWnd as ulong,_ 'window handle file$ as ptr,_ 'disk filename of image ImageHandle as ulong 'handle of image in memory close #j
loadbmp "myPic", ImageHandle
open "JPG" for graphics_nsb_nf as #1 #1 "trapclose [quit]" #1 "down; drawbmp myPic 0 0;flush"
REM*****************PLAY SOUND
playwave "c:\Bantam\Bantam_project\cock-crowing.wav", async
'wait prompt "Ready to go?"; a$ key$ = inkey$ 'gosub [mainprogram] close #1 'close "JPG" for graphics as #1
nomainwin WindowWidth = 1370 WindowHeight = 768
UpperLeftX = int((DisplayWidth - WindowWidth)/2) UpperLeftY = int((DisplayHeight - WindowHeight)/2) file$ = "C:\Bantam\Bantam_project\Surround.jpg"
open "jpeg.dll" for DLL as #j calldll #j, "LoadImageFile",_ hWnd as ulong,_ 'window handle file$ as ptr,_ 'disk filename of image ImageHandle as ulong 'handle of image in memory close #j
loadbmp "myPic", ImageHandle
open "JPG" for graphics_nsb_nf as #1
#1 "trapclose [quit]" #1 "down; drawbmp myPic 0 0;flush"
REM****************Load main program
run "c:\Bantam\Newbantam.tkn"
cls close #1
end
|
|
|
Post by Rod on Oct 21, 2020 12:49:44 GMT -5
Ah the tutor has intervened!
I would suggest that you dont assume everyone has the same screen size 1370,768. Is that your screen size? DisplayWidth DisplayHeight will get you the correct size. You don't seem to get the .jpg size but perhaps you know it. You can only place the graphic if you know the screen dimension and the graphic image dimension. So your display window fits the graphic or you centre the window and graphic and display as best you can. It may overflow the screen or it may only fill a small portion of centre screen.
Look at the code to place the window centre screen, same kind of code will place the graphic window centre screen. But easier to display a known graphic size in a known graphic window size.
Other than that my advice is that Splash Screens suck and very few users enjoy them.
|
|
|
Post by bigbrix on Oct 21, 2020 13:42:57 GMT -5
Thank you, I'll carry on trying. I've just realised that I did not provide the actual program I was running, so you would not have seen my problem! Not sure how you would use it, but here it is. This is the .bas program, but I have of course made a .tkn file.
REM INITIALISE GLOBAL div DIM lp(6, 24), tf(6,24), ln$(6), lt$(6,24), match(6,24), match2 (6,24), nt(6), pd(36,36), qp(5) let qp(1) = 0.4 qp(2) = 0.7 qp(3) = 1 qp(4) = 1.3 qp(5) = 1.1 kwp = 15 GOSUB[readdivisionnames] GOSUB[getteams] blank$ = " "
'MAINWIN 60 30 [options] 'CLS :
PRINT TAB(23); " OPTIONS": PRINT PRINT TAB(10); "SET UP LEAGUE POSITION RECORDS"; TAB(45); 1 PRINT TAB(10); "SET UP TEAM PERFORMANCE RECORDS"; TAB(45); 2 PRINT TAB(10); "INPUT MOST RECENT RESULTS"; TAB(45); 3 PRINT TAB(10); "CREATE MATCH LIST"; TAB(45); 4 PRINT TAB(10); "PREDICT NEXT WEEKS DRAWS"; TAB(45); 5 PRINT TAB(10); "SAVE DATABASE"; TAB(45); 6 PRINT TAB(10); "CREATE THE DATABASE"; TAB(45); 7 PRINT TAB(10); "LOAD THE DATABASE"; TAB(45); 8 PRINT TAB(10); "FINISH"; TAB(45); 9 PRINT:PRINT:PRINT: PRINT TAB(10); end
|
|
|
Post by bigbrix on Oct 24, 2020 9:53:48 GMT -5
Worked it out for myself, Cheers
|
|
|
Post by tsh73 on Oct 24, 2020 14:11:42 GMT -5
Please explain your solution so others could benefit.
|
|