*SCREENSAVE - NOT!
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: *SCREENSAVE - NOT!
Ah, ok. Still, not much help when I am using Windows, not Linux, but thanks for your comments.
Re: *SCREENSAVE - NOT!
Hi KenDown,
You say the picture is in the main window, and is the bit being saved by *SCREENSAVE, but how are you generating the transparent window in which you are writing text? Are you using the Multiwin library to generate an extra window, making that transparent, and positioning it over the "main" window? Do the two windows coincide exactly?
If you can let me know what you are doing, I'll try to reproduce it and see if I can work out a solution. Better still if you can post minimal code to save me writing it!

D
You say the picture is in the main window, and is the bit being saved by *SCREENSAVE, but how are you generating the transparent window in which you are writing text? Are you using the Multiwin library to generate an extra window, making that transparent, and positioning it over the "main" window? Do the two windows coincide exactly?
If you can let me know what you are doing, I'll try to reproduce it and see if I can work out a solution. Better still if you can post minimal code to save me writing it!

D
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: *SCREENSAVE - NOT!
Sorry, for some reason this thing stopped letting me know when there was a reply to my post.
Yes, I am using the multi-win library and yes, the two windows coincide exactly - same size, same location on the screen (ie. full screen). Rather than trying to extract program snippets and find that they don't work because some routine has been omitted, go to http://www.nwtv.co.uk/display/ and download the Display program. It's a zip file so will have to be extracted.
Once extracted and running, click on File=>New and save a text file, then click the first number in the squares on the left (a button with zero in it), drag a picture then cut'n'paste the following
|NFNkkdswapover("",0,"Prevenient Grace",9,"Arial Bold",72)
Click "Finish", press f5 or click on "Display (f5)". Press <Ctrl>+<R> to initiate and <Ctrl>+<S> to actually save a picture.
The code is included in the zip file. The transparent overlay is set up in DEFPROCpresentation which calls FNcreatetransparent(). The screensave is in PROCsavescreen and FNkkdswapover is in the library Test.bbc
I hope all that isn't too complicated - and thanks for the offer of help.
Yes, I am using the multi-win library and yes, the two windows coincide exactly - same size, same location on the screen (ie. full screen). Rather than trying to extract program snippets and find that they don't work because some routine has been omitted, go to http://www.nwtv.co.uk/display/ and download the Display program. It's a zip file so will have to be extracted.
Once extracted and running, click on File=>New and save a text file, then click the first number in the squares on the left (a button with zero in it), drag a picture then cut'n'paste the following
|NFNkkdswapover("",0,"Prevenient Grace",9,"Arial Bold",72)
Click "Finish", press f5 or click on "Display (f5)". Press <Ctrl>+<R> to initiate and <Ctrl>+<S> to actually save a picture.
The code is included in the zip file. The transparent overlay is set up in DEFPROCpresentation which calls FNcreatetransparent(). The screensave is in PROCsavescreen and FNkkdswapover is in the library Test.bbc
I hope all that isn't too complicated - and thanks for the offer of help.
Re: *SCREENSAVE - NOT!
Wow! That's quite a program! I haven't had a chance to get to grips with it yet.
I DID have a look at using multiwin and Alt-Printscreen in a simple case. Here I've made a main window and done some drawing in it. Then I've made an additional window, made it transparent,and done some (different) drawing in that. Note that I have NOT hidden the frame etc, so you can see where it is, and move it around (you have 4 seconds!) - just the main window area is transparent. It's possible (by changing the MODE commands) to make the windows different sizes.
I've written a small routine to synthesise the Alt-PrtScn, and it does generate an image relating to the selected window area on the clipboard. The image includes everything you can see through the window, so it DOES look like it's a possible approach. You can check the image generated by pasting it into Word, your favourite painting package or whatever, but we want programmatic control....
...and that's where it all goes horribly wrong. My basic plan was to load or copy the clipboard image data into the main window, and then you could use *SCREENSAVE as you are at present.
IsClipboardFormatAvailable (usually) reports that we can have a bitmap (or a DIB), but then GetClipboardData fails to get a valid handle. At one stage I DID manage to get it to get data and post something like it into the main window, but in trying to improve it I broke it - I suspect I was relying on something fluky in memory, and the image wasn't correct (it looked like an overlapped version of itself, perhaps because of a size mismatch in the data). I've tried making an extra device context, and loading the bitmap into there, but that fails too (not surprising, since the window handle is 0!).
Don't know if that's useful at all (the snapshot routine might be!). If anyone can explain what stupidity I am commiting in getting hold of the clipboard data, I'd be grateful!
Best wishes,
D
I DID have a look at using multiwin and Alt-Printscreen in a simple case. Here I've made a main window and done some drawing in it. Then I've made an additional window, made it transparent,and done some (different) drawing in that. Note that I have NOT hidden the frame etc, so you can see where it is, and move it around (you have 4 seconds!) - just the main window area is transparent. It's possible (by changing the MODE commands) to make the windows different sizes.
I've written a small routine to synthesise the Alt-PrtScn, and it does generate an image relating to the selected window area on the clipboard. The image includes everything you can see through the window, so it DOES look like it's a possible approach. You can check the image generated by pasting it into Word, your favourite painting package or whatever, but we want programmatic control....
...and that's where it all goes horribly wrong. My basic plan was to load or copy the clipboard image data into the main window, and then you could use *SCREENSAVE as you are at present.
IsClipboardFormatAvailable (usually) reports that we can have a bitmap (or a DIB), but then GetClipboardData fails to get a valid handle. At one stage I DID manage to get it to get data and post something like it into the main window, but in trying to improve it I broke it - I suspect I was relying on something fluky in memory, and the image wasn't correct (it looked like an overlapped version of itself, perhaps because of a size mismatch in the data). I've tried making an extra device context, and loading the bitmap into there, but that fails too (not surprising, since the window handle is 0!).
Don't know if that's useful at all (the snapshot routine might be!). If anyone can explain what stupidity I am commiting in getting hold of the clipboard data, I'd be grateful!
Best wishes,
D
Code: Select all
INSTALL @lib$+"WINLIB5A"
INSTALL @lib$+"MULTIWIN"
PROC_multiwin(1)
newwnd%=FN_createwin(1, "Overlay", 0, 0, 800, 600, 0, &96C00000, 0)
MODE 21
PRINT "Here is the main window!"
GCOL 1
RECTANGLE FILL 100,100,800,400
GCOL 4
RECTANGLE FILL 200,200,300,400
PROC_selectwin(1)
MODE 21
transparent% = TINT(0,0)
GWL_EXSTYLE = -20
WS_EX_LAYERED = &80000
SYS "SetWindowLong", @hwnd%, GWL_EXSTYLE, WS_EX_LAYERED
SYS "SetLayeredWindowAttributes", @hwnd%, transparent%, 0, 1
COLOUR 4
PRINT "Here is the extra window!"
GCOL 2
RECTANGLE FILL 100,100,800,300
GCOL 3
RECTANGLE FILL 200,200,300,600
WAIT 400 :REM Wait 4 seconds - gives you time to move the transparent window
SYS "OpenClipboard", @hwnd%
PROCSnapshotWindow
PROC_selectwin(0)
PROC_closewin(1)
SYS "IsClipboardFormatAvailable", 2 TO res%
IF res% THEN PRINT"YEs we have a bitmap!";res% ELSE PRINT "says its not there"
REM OK so far, but now it all goes horribly wrong!
REM The next bit fails, and I haven't worked out why...
SYS "GetClipboardData", 2 TO bmhand%
PRINT bmhand%
IF bmhand% THEN
SYS "SelectObject",@memhdc%, bmhand% TO oldbm%
SYS "InvalidateRect",@hwnd%,0,0
WAIT 200
SYS "SelectObject",@memhdc%, oldbm% TO bmhand%
SYS "DeleteObject",bmhand%
ENDIF
SYS "CloseClipboard"
END
:
DEFPROCSnapshotWindow
LOCAL vk_snapshot%,vk_menu%
vk_snapshot%=&2C :REM Print screen key
vk_menu%=&12 :REM Alt key
REM synthesise pressing Alt-PrtScn, to copy the active window to the clipboard
SYS "keybd_event",vk_menu% ,0,0,0 :REM Press alt
SYS "keybd_event",vk_snapshot% ,0,0,0 :REM Press PrtScn
SYS "keybd_event",vk_snapshot% ,0,2,0 :REM Release PrtScn
SYS "keybd_event",vk_menu% ,0,2,0 :REM Release alt
ENDPROC
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: *SCREENSAVE - NOT!
Hmmm. It's probably not supposed to, but I get "says it's not there" every time, so it seems to be failing from the start. Of course, that *could* be because I'm using XP - I'll try with Win10 later on when I turn that computer on.
Thanks for your efforts.
Thanks for your efforts.
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: *SCREENSAVE - NOT!
This is interesting. Just to see what would happen, I inserted "END" after the WAIT 400 and then pressed <Alt+PrtScr>. I started up the Gimp and tried <Ctrl+V> and it pasted in the transparent window only. I then ran the program again and during the WAIT I click on the top border of the lower window and this time both windows were pasted into the Gimp.
I then put PROC_selectwin(0) in before the WAIT, removed the END and the program now runs fine and both windows appear when I paste into the Gimp. It's possible that that is the problem with the program. Curiously, though, I don't get the "Yes, we have a bitmap" message.
I then put PROC_selectwin(0) in before the WAIT, removed the END and the program now runs fine and both windows appear when I paste into the Gimp. It's possible that that is the problem with the program. Curiously, though, I don't get the "Yes, we have a bitmap" message.
Re: *SCREENSAVE - NOT!
Hi KenDown,
I am reasonably confident that my code always captures the snapshot to the clipboard - I can always paste it into another programme - but my understanding/control of programmatic access to bitmaps on the clipboard is clearly faulty. I usually (but not always) DO get a report that a bitmap (or DIB) is available - but even when not I can paste it, so it is really!
You will note that I've grabbed the snapshot while the transparent window is selected,and it does collect the stuff below it. In some ways I'd be more surprised if grabbing the main window (which is "below" the transparent one) also grabbed both. but if it's capturing what's on screen, it's not THAT surprising!
I doubt if it's a WinXP/Win10 thing - I'm working on Win7, for what it's worth - but I guess it could be.
If anyone can post simple code to copy a clipboard bitmap to the main window, I'd be grateful. I may have a chance to have another play later.
best wishes,
D
I am reasonably confident that my code always captures the snapshot to the clipboard - I can always paste it into another programme - but my understanding/control of programmatic access to bitmaps on the clipboard is clearly faulty. I usually (but not always) DO get a report that a bitmap (or DIB) is available - but even when not I can paste it, so it is really!
You will note that I've grabbed the snapshot while the transparent window is selected,and it does collect the stuff below it. In some ways I'd be more surprised if grabbing the main window (which is "below" the transparent one) also grabbed both. but if it's capturing what's on screen, it's not THAT surprising!
I doubt if it's a WinXP/Win10 thing - I'm working on Win7, for what it's worth - but I guess it could be.
If anyone can post simple code to copy a clipboard bitmap to the main window, I'd be grateful. I may have a chance to have another play later.
best wishes,
D
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: *SCREENSAVE - NOT!
Well, I'm just reporting what my experience was.
Annoyingly, there is information in the Help on how to extract text from the clipboard but nothing on how to get a picture out. (See "Using the clipboard") On the Wiki there is an article "Putting an image on the clipboard", but there doesn't appear to be the complementary "Getting an image from the clipboard". There isn't a search facility on the Wiki, which is a nuisance.
Annoyingly, there is information in the Help on how to extract text from the clipboard but nothing on how to get a picture out. (See "Using the clipboard") On the Wiki there is an article "Putting an image on the clipboard", but there doesn't appear to be the complementary "Getting an image from the clipboard". There isn't a search facility on the Wiki, which is a nuisance.
Re: *SCREENSAVE - NOT!
Have you tried this bit:
http://www.bbcbasic.co.uk/wiki/doku.php ... a_20window
Method 2 looks pretty close to what I was working towards anyway, which is a bit embarassing! Can you adapt that?
Best wishes,
D
http://www.bbcbasic.co.uk/wiki/doku.php ... a_20window
Method 2 looks pretty close to what I was working towards anyway, which is a bit embarassing! Can you adapt that?
Best wishes,
D
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: *SCREENSAVE - NOT!
If you look back up the thread you'll see that someone else has made the same suggestion, but it didn't work. Not sure why.