PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 8 9 [10]
 91 
 on: January 21, 2019, 03:55:15 AM 
Started by Paul Squires - Last post by Josť Roca
The Chinese.lang file that comes with this package is bad. It is full of ???.

 92 
 on: January 21, 2019, 03:15:03 AM 
Started by Paul Squires - Last post by Josť Roca
I remember that it worked in a much older version. Don't know in which version started happening.

 93 
 on: January 21, 2019, 03:13:17 AM 
Started by Paul Squires - Last post by Josť Roca
> I am wondering if it will require being on a Russian version of Windows.

No. It works in this test:

Code: [Select]
' ########################################################################################
' Microsoft Windows
' Contents: Demonstrates the use of the Edit control.
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2016 Josť Roca. Freeware. Use at your own risk.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################

#define UNICODE
#INCLUDE ONCE "Afx/CWindow.inc"
#INCLUDE ONCE "Afx/CTextStream.inc"
USING Afx

CONST IDC_EDIT1 = 1001

DECLARE FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                          BYVAL hPrevInstance AS HINSTANCE, _
                          BYVAL szCmdLine AS ZSTRING PTR, _
                          BYVAL nCmdShow AS LONG) AS LONG

   END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)

' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                  BYVAL hPrevInstance AS HINSTANCE, _
                  BYVAL szCmdLine AS ZSTRING PTR, _
                  BYVAL nCmdShow AS LONG) AS LONG

   ' // Set process DPI aware
   AfxSetProcessDPIAware

   ' // Create the main window
   DIM pWindow AS CWindow
   pWindow.Create(NULL, "Edit controls", @WndProc)
   pWindow.SetClientSize 400, 200
   pWindow.Center

   ' // Add an Edit control
   DIM hEdit AS HWND = pWindow.AddControl("Edit", , IDC_EDIT1, "", 20, 15, 305, 23)

   ' // Set the focus in the first edit control
   SetFocus hEdit

dim idx as long
   ' // Create an instance of the CTextStream class
DIM pTxtStm AS CTextStream
' // Open file as a text stream
DIM cbsFile AS CBSTR = ExePath & $"\russian.lang"
DIM cbs AS CBSTR
IF pTxtStm.OpenUnicode(cbsFile) = S_OK THEN
   ' // Read the file sequentially
   DO UNTIL pTxtStm.EOS
      cbs = pTxtStm.ReadLine
      idx = idx + 1
      if idx > 20 then exit do
   LOOP
   pTxtStm.Close
END IF

DIM i as long
i = Instr(cbs, ":")
cbs = Mid(**cbs, i+1)
SetWindowText hEdit, cbs
cbs = rtrim(AfxStrParse(cbs, 1, ";"), any chr(9,32))


   ' // Dispatch Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

END FUNCTION
' ========================================================================================

' ========================================================================================
' Main window callback procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

   SELECT CASE uMsg

      CASE WM_COMMAND
         SELECT CASE GET_WM_COMMAND_ID(wParam, lParam)
            ' // If ESC key pressed, close the application sending an WM_CLOSE message
            CASE IDCANCEL
               IF GET_WM_COMMAND_CMD(wParam, lParam) = BN_CLICKED THEN
                  SendMessageW hwnd, WM_CLOSE, 0, 0
                  EXIT FUNCTION
               END IF
         END SELECT

    CASE WM_DESTROY
         ' // End the application
         PostQuitMessage(0)
         EXIT FUNCTION

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = DefWindowProcW(hWnd, uMsg, wParam, lParam)

END FUNCTION
' ========================================================================================

 94 
 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

 95 
 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.

 96 
 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.

 97 
 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)

 98 
 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


 99 
 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 "????").

 100 
 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.

Pages: 1 ... 8 9 [10]