Ooops
March 01, 2021, 10:55:19 PM

Author Topic: [bb] display image on desktop by b32 [ 1+ years ago ]  (Read 483 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] display image on desktop by b32 [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : display image on desktop
Author : b32
Posted : 1+ years ago

Description : I'm not sure if the loaded bitmap needs to be cleaned up after usage. I've tested this code on my pc and I was able to draw the image all over the desktop. It doesn't remove it, however, I can imagine you can copy a portion of the desktop before drawing onto it, and place it back afterwards. The program was based on several programs I found on the net.

In combination with the hack to hide your startup window, this can be used for splash screens.
<a href="../Community/posts6a98-2.html?topic=37093" target="_blank">http://www.blitzbasic.com/Community/posts.php?topic=37093[/url]


Code :
Code: BlitzBasic
  1. ;--------------------------------------------------------------------------------
  2. ;                                                               draw image on desktop
  3. ;--------------------------------------------------------------------------------
  4.  
  5.  
  6.         Const bmpname$ = "earth.bmp"
  7.  
  8.         ;load image            
  9.         image = api_LoadImage(0, bmpname$, 0, 0, 0, $10)
  10.        
  11.         ;get desktop dc
  12.         hdc = api_GetDC(0)
  13.  
  14.         ;create new dc and place image on it
  15.         hdc2 = api_CreateCompatibleDC(hdc)
  16.         api_SelectObject(hdc2, image)
  17.                        
  18.         ;copy data
  19.         api_BitBlt(hdc, 0, 0, 256, 256, hdc2, 0, 0, $CC0020)
  20.        
  21.         ;clean up dcs
  22.         api_ReleaseDC(DeskHwnd, hdc)
  23.         api_DeleteDC(hdc2)
  24.        
  25.         WaitKey()
  26.         End
  27.  
  28.  
  29. ;--------------------------------------------------------------------------------
  30. ;save these lines as a .decls file in the program fileslitzuserlibs directory
  31. ;--------------------------------------------------------------------------------
  32.                
  33. ;       .lib "user32.dll"
  34. ;      
  35. ;       api_LoadImage% (hInst%, lpsz$, un1%, n1%, n2%, un2%) : "LoadImageA"
  36. ;       api_ReleaseDC%(hWnd%,hDC%) : "ReleaseDC"
  37. ;       api_GetDC%(hWnd%) : "GetDC"
  38. ;      
  39. ;      
  40. ;       .lib "gdi32.dll"
  41. ;      
  42. ;       api_BitBlt%(hDestDC%,X%,Y%,nWidth%,nHeight%,hSrcDC,XSrc,YSrc,dwRop) : "BitBlt"
  43. ;       api_CreateCompatibleDC% (hdc%) : "CreateCompatibleDC"
  44. ;       api_SelectObject% (hdc%, hObject%) : "SelectObject"
  45. ;       api_DeleteDC% (hdc%) : "DeleteDC"


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal