Announcement

Collapse
No announcement yet.

inputbox$

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • inputbox$

    I apprecisted if someone can guide me for the following question.

    The purpose of INPUTBOX$ is to displays a dialog box containing a prompt and also remarks said" Prompt$ is the text prompt displayed in the Inputbox dialog" , My question is it seems the Prompt$ could not be using Chinese character, as I tried to compile the file with chinese character prompt$ for the inputbox$ function but the inputbox dialog display the incorrect chinese character which is not same as the Prompt$ I used. Could some one tell me how to fix it? Thanks in advance...
    Frank Chu
    Home Club International corp.
    Golden Fox International corp.
    www.sheryl-spa.com
    www.kingrocks.com
    [email protected]

  • #2
    Hi Frank,
    here is one way using a Börge/Semen technique...

    Code:
    
    #COMPILE EXE '#Win 8.04#
    #DIM ALL
    #REGISTER NONE
    #INCLUDE "Win32Api.inc" '#2005-01-27#
     
    GLOBAL hDlg  AS DWORD
    GLOBAL hHook AS DWORD
    GLOBAL hFont AS DWORD
     
    %BUTTON1  = 301
    '______________________________________________________________________________
     
    FUNCTION chmEnumCharSet(elf AS ENUMLOGFONT, ntm AS NEWTEXTMETRIC, _
                            BYVAL FontType AS LONG, CharSet AS LONG) AS LONG
     
     CharSet = elf.elfLogFont.lfCharSet
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION MakeFontEx(BYVAL FontName AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
                        BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG) AS DWORD
     LOCAL hDC      AS DWORD
     LOCAL CharSet  AS LONG
     LOCAL CyPixels AS LONG
     
     hDC = GetDC(%HWND_DESKTOP)
     CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
     EnumFontFamilies hDC, BYVAL STRPTR(FontName), CODEPTR(chmEnumCharSet), BYVAL VARPTR(CharSet)
     ReleaseDC %HWND_DESKTOP, hDC
     PointSize = 0 - (PointSize * CyPixels) \ 72
     
     FUNCTION = CreateFont(PointSize, 0, _  'Height, width(default=0)
                0, 0, _                     'Escapement(angle), orientation
                fBold, _                    'Weight (%FW_DONTCARE = 0, %FW_NORMAL = 400, %FW_BOLD = 700)
                fItalic, _                  'Italic
                fUnderline, _               'Underline
                %FALSE, _                   'StrikeThru
                CharSet, %OUT_TT_PRECIS, _
                %CLIP_DEFAULT_PRECIS, %DEFAULT_QUALITY, _
                %FF_DONTCARE , BYCOPY FontName)
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION HookNextDialog(BYVAL lMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
     
      IF lMsg = %HCBT_ACTIVATE THEN
        hFont = MakeFontEx("Wingdings", 10, %FW_BOLD, 0, 0)    'Change to desired font
        IF hFont THEN
          CONTROL SEND wParam, 101, %WM_SETFONT, hFont, 0      'Tell edit control to use this font
          CONTROL SEND wParam, 102, %WM_SETFONT, hFont, 0      'Tell static control to use this font
        END IF
        UnhookWindowsHookEx hHook
      END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    CALLBACK FUNCTION DlgProc
     LOCAL sResult AS STRING
     
     SELECT CASE CBMSG
     
       CASE %WM_COMMAND
         SELECT CASE LOWRD(CBWPARAM)
           CASE %BUTTON1
             IF CBCTLMSG = %BN_CLICKED THEN
               hHook = SetWindowsHookEx(%WH_CBT, CODEPTR(HookNextDialog), GetModuleHandle(""), GetCurrentThreadId)
               sResult = INPUTBOX$("Prompt", "Title", "Default")
             END IF
         END SELECT
     
       CASE %WM_DESTROY
          IF hFont THEN DeleteObject hFont
     
      END SELECT
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PBMAIN()
     
     DIALOG NEW %HWND_DESKTOP, "Inputbox Font", , , 200, 100, _
       %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU, 0 TO hDlg
     
     CONTROL ADD BUTTON, hDlg, %BUTTON1, "Inputbox", 75, 40, 50, 20
     
     DIALOG SHOW MODAL hDlg CALL DlgProc
     
    END FUNCTION
    '______________________________________________________________________________
    '
    
    Last edited by Pierre Bellisle; 28 Mar 2008, 05:00 PM.

    Comment


    • #3
      Hi Pierre,

      Thanks for your help. But It seems can not solve the the problem. When I add a MSGBOX" CHINESE STRING" into your program and it will display a message excatly as " CHINESE STRING" without any problem, Howerver at mean time, I also add same Chinese string as promt$ into your proram, the INPUTBOX$(" CHINESE STRING HERE","CHINESE TITILE HERE", " " ), the result won't dispaly the promt$ exactly as " CHINESE STRING HERE" I added. Anyone can help? Appreciated.
      Frank Chu
      Home Club International corp.
      Golden Fox International corp.
      www.sheryl-spa.com
      www.kingrocks.com
      [email protected]

      Comment


      • #4
        Frank,

        You may need To create your own 'Input Dialog' using unicode controls.
        Example code posted by Kev Peel: http://www.powerbasic.com/support/pb...ad.php?t=25051
        (Discussed here: http://www.powerbasic.com/support/pb...ad.php?t=13803 )

        This discussion might be of interest too: http://www.powerbasic.com/support/pb...ad.php?t=13865

        As I understand it PowerBASIC (DDT) creates ANSI controls and the way that characters are displayed depends upon the regional setting on your PC (current ANSI code page). This can be overcome by using unicode functions.
        Rgds, Dave

        Comment


        • #5
          Hi Dave,

          Thanks, I will stdudy it and study...., It is a good point about to create my own 'input Dialog' and another one is your last sentence "As I understand it PowerBASIC (DDT) creates ANSI controls and the way that characters are displayed depends upon the regional setting on your PC (current ANSI code page). This can be overcome by using unicode functions." Thanks again
          Frank Chu
          Home Club International corp.
          Golden Fox International corp.
          www.sheryl-spa.com
          www.kingrocks.com
          [email protected]

          Comment

          Working...
          X