PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 10
 1 
 on: January 20, 2019, 08:03:30 PM 
Started by Paul Squires - Last post by Paul Squires
Hi Josť,

I couldn't find a function in WinFBX that extracts a resource to a file so I stole some of your other code and put together the code below. Maybe you'll find it useful and include it in the library at some point.

I needed such a function because as you've noted in your CImageCtx control some image types can't be loaded from a resource. I created a PictureBox control for the WinFBE visual designer and it extracts the image to a temp file and uses the LoadImageFromFile function that works well loading the different file types.

Code: [Select]
function AfxExtractResourceToFile( byval hInstance as HINSTANCE, _
                                   byref wszResourceName as wstring, _
                                   byref wszFileName as wstring, _
                                   byval lResourceType as LPWSTR _
                                   ) as boolean
   ' Default that the function is successful
   dim AS LONG lResult = true
   
   ' // Find the resource and lock it
   DIM hResource AS HRSRC = FindResourceW(hInstance, wszResourceName, CAST(LPCWSTR, lResourceType))
   IF hResource = NULL THEN RETURN false
   
   DIM imageSize AS DWORD = SizeofResource(hInstance, hResource)
   IF imageSize = 0 THEN RETURN false
   
   DIM pResourceData AS LPVOID = LockResource(LoadResource(hInstance, hResource))
   IF pResourceData = NULL THEN RETURN false
   
   ' // Allocate memory to hold the image
   DIM hGlobal AS HGLOBAL = GlobalAlloc(GMEM_MOVEABLE, imageSize)
   IF hGlobal THEN
      ' // Lock the memory
      DIM pGlobalBuffer AS LPVOID = GlobalLock(hGlobal)
      IF pGlobalBuffer THEN
         
         ' // Copy the image from the resource file to global memory
         memcpy pGlobalBuffer, pResourceData, imageSize

         AfxDeleteFile( wszFileName )
         dim as long f = freefile
         if open( wszFileName, for binary, as #f ) = 0 then
            dim pBuffer as byte ptr = pGlobalBuffer
            put #f, , pBuffer[0], imagesize       
            close #f
         else
            return true
         end if
         ' // Unlock the memory
         GlobalUnlock pGlobalBuffer
      END IF
      ' // Free the memory
      GlobalFree hGlobal
   END IF

   function = lResult
end function

 2 
 on: January 20, 2019, 04:14:23 PM 
Started by Paul Squires - Last post by Paul Squires
When I switch to Russian and restart WinFBE, the entire application shows "??????" for text. I am wondering if it will require being on a Russian version of Windows. I do have #Define UNICODE defined for the compiled version of WinFBE.

 3 
 on: January 20, 2019, 04:01:33 PM 
Started by Paul Squires - Last post by Paul Squires
is the options - build configurations - working properly? It seems stuck on win32 console (release)
I fixed that yesterday if I remember correctly.... it was not saving between sessions. I will upload another package tonight if I get this Russian font thing figured out.

 4 
 on: January 20, 2019, 03:48:52 PM 
Started by Paul Squires - Last post by raymw
is the options - build configurations - working properly? It seems stuck on win32 console (release)

 5 
 on: January 20, 2019, 03:19:06 PM 
Started by Paul Squires - Last post by Paul Squires
I wonder if the following may be the problem (issue with the font?) because I am using a unicode edit control (from CWindow). I will try setting a different font and see what happens......

https://stackoverflow.com/questions/7153340/russian-characters-not-showing-up-correctly-in-mfc-unicode-list-box

https://stackoverflow.com/questions/8742882/display-arabic-unicode-in-mfc-view?rq=1


 6 
 on: January 20, 2019, 02:52:51 PM 
Started by Paul Squires - Last post by Josť Roca
The localization editor doesn't display correctly the translated phrase for languages like Russian or Chinese (it displays "????").

 7 
 on: January 20, 2019, 01:39:52 PM 
Started by Paul Squires - Last post by Paul Squires
Sorry, Paul, bit of overlap in our posts. I've moved on from that original problem, not sure if I can find the project, may have deleted it. I noticed since, that the basic file that I thought was in that project, was in fact in another one I opened - due to the fact that closing does not include removing, which i originally expected. (I've still got the project file, I'll try and get it to you.)
Hi Ray, I got the two .wfbe project files that you emailed me. You are correct with your assessment of the problem. You had the file open at the same time in two different projects.

 8 
 on: January 20, 2019, 01:10:27 PM 
Started by Paul Squires - Last post by Josť Roca
Quote
I generate an array of numbers and copy them to a text box with a vertical scroll bar. I've noticed that if the list is more than about a 1000 values, that said text box flickers a lot, but in most cases it eventually stabilizes, and I can then access the list by means of the scroll bars.

Assuming that you are using a loop, disable redrawing with SetWindowRedraw(<handle of the control>, FALSE) before starting the loop and enable it again when the loop ends with SetWindowRedraw(<handle of the control>, TRUE). If you aren't using a loop, then tell us what you're doing.

Quote
However, if I try to use the scroll bars before it stops flickering, a message pops up to the effect it is not responding. A list of 5000 items takes about 50 seconds for the text box to be usable, I gave up on 10,0000 items. It is not that obvious when the text box is complete, perhaps I need to add a bell, or whistle...

When using a tight loop, the control won't be responsible until the loop ends unles you allow Windows to process pending messages calling the procedure AfxDoEvents inside the loop.


 9 
 on: January 20, 2019, 12:32:17 PM 
Started by Paul Squires - Last post by raymw
Sorry, Paul, bit of overlap in our posts. I've moved on from that original problem, not sure if I can find the project, may have deleted it. I noticed since, that the basic file that I thought was in that project, was in fact in another one I opened - due to the fact that closing does not include removing, which i originally expected. (I've still got the project file, I'll try and get it to you.)

 10 
 on: January 20, 2019, 12:21:19 PM 
Started by Paul Squires - Last post by raymw
No problem with what I'm doing, but gave me a question or two. What is the limit for the number of lines you can have in a text box? I generate an array of numbers and copy them to a text box with a vertical scroll bar. I've noticed that if the list is more than about a 1000 values, that said text box flickers a lot, but in most cases it eventually stabilizes, and I can then access the list by means of the scroll bars. However, if I try to use the scroll bars before it stops flickering, a message pops up to the effect it is not responding. A list of 5000 items takes about 50 seconds for the text box to be usable, I gave up on 10,0000 items. It is not that obvious when the text box is complete, perhaps I need to add a bell, or whistle...

Pages: [1] 2 3 ... 10