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