duilib 实现软键盘

窗口样式:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Window size="955,275" caption="0,0,0,90" mininfo="600,275">
  <Font name="微软雅黑" size="20" bold="false" italic="false" default="true" />
  <Font name="楷书" size="13" bold="false" italic="false" />
  <VerticalLayout width="955" height="275">
    <HorizontalLayout width="955" height="20">
      <Button name="closebtn" text="x" float="true" pos="910,1,0,0" width="30" height="18" bkcolor="#FF000000" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
    </HorizontalLayout>
    <TabLayout name="switch">
      <VerticalLayout width="954" height="254">
        <Button name="btn_81" text="q" float="true" pos="9,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_87" text="w" float="true" pos="87,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_69" text="e" float="true" pos="165,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_82" text="r" float="true" pos="243,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_84" text="t" float="true" pos="321,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_89" text="y" float="true" pos="399,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_85" text="u" float="true" pos="477,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_73" text="i" float="true" pos="555,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_79" text="o" float="true" pos="633,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_80" text="p" float="true" pos="711,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="lbtn_8" text="Backspace" float="true" pos="793,5,0,0" width="150" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_65" text="a" float="true" pos="38,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_83" text="s" float="true" pos="115,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_68" text="d" float="true" pos="192,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_70" text="f" float="true" pos="269,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_71" text="g" float="true" pos="346,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_72" text="h" float="true" pos="423,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_74" text="j" float="true" pos="500,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_75" text="k" float="true" pos="577,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_76" text="l" float="true" pos="654,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_222" text="&apos;" float="true" pos="731,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="lbtn_13" text="Enter" float="true" pos="813,67,0,0" width="130" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Option name="opt_shiftl" text="Shift" float="true" pos="9,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedtextcolor="#FF000000" selectedimage="selected.png" />
        <Button name="btn_90" text="z" float="true" pos="87,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_88" text="x" float="true" pos="165,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_67" text="c" float="true" pos="243,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_86" text="v" float="true" pos="321,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_66" text="b" float="true" pos="399,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_78" text="n" float="true" pos="477,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_77" text="m" float="true" pos="555,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_188" text="," float="true" pos="633,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_190" text="." float="true" pos="711,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="symbol_191" text="?" float="true" pos="789,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Option name="opt_shiftr" text="Shift" float="true" pos="872,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedtextcolor="#FF000000" selectedimage="selected.png" />
        <Button name="handinput" text="手写板" float="true" pos="165,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_32" text="空格" float="true" pos="249,191,0,0" width="460" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_37" text="&lt;-" float="true" pos="717,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
        <Button name="btn_39" text="-&gt;" float="true" pos="795,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" pushedtextcolor="#FF000000" />
      </VerticalLayout>
      <VerticalLayout width="954" height="254">
        <TabLayout name="sswitch">
          <VerticalLayout float="true" pos="87,0,0,0" width="470" height="185">
            <Button name="symbol_49" text="!" float="true" pos="0,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_57" text="(" float="true" pos="0,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_220" text="\" float="true" pos="0,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_50" text="@" float="true" pos="78,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_48" text=")" float="true" pos="78,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_186" text=";" float="true" pos="78,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_51" text="#" float="true" pos="156,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_189" text="-" float="true" pos="156,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_186" text=":" float="true" pos="156,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_52" text="$" float="true" pos="234,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_189" text="_" float="true" pos="234,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_222" text="&quot;" float="true" pos="234,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_53" text="%" float="true" pos="312,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_187" text="=" float="true" pos="312,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_106" text="*" float="true" pos="312,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_55" text="&amp;" float="true" pos="390,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_107" text="+" float="true" pos="390,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_191" text="/" float="true" pos="390,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
          </VerticalLayout>
          <VerticalLayout float="true" pos="87,0,0,0" width="470" height="185">
            <Button name="symbol_188" text="&lt;" float="true" pos="0,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_220" text="|" float="true" pos="0,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_190" text="&gt;" float="true" pos="78,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_192" text="~" float="true" pos="78,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_219" text="[" float="true" pos="156,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_54" text="^" float="true" pos="156,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="btn_221" text="]" float="true" pos="234,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_219" text="{" float="true" pos="312,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button name="symbol_221" text="}" float="true" pos="390,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
           
            <Button enabled="false" text="" float="true" pos="312,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button enabled="false" text="" float="true" pos="390,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button enabled="false" text="" float="true" pos="390,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button enabled="false" text="" float="true" pos="312,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
            <Button enabled="false" text="" float="true" pos="234,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
          </VerticalLayout>
        </TabLayout>
        <Button name="btn_37" text="&lt;-" float="true" pos="243,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_39" text="-&gt;" float="true" pos="321,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_9" text="Tab" float="true" pos="9,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
       
        <Button name="rsymbol" text="下一页" float="true" pos="9,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button enabled="false" text="" float="true" pos="165,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_32" text="空格" float="true" pos="399,191,0,0" width="150" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_97" text="1" float="true" pos="590,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_100" text="4" float="true" pos="590,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_103" text="7" float="true" pos="590,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_96" text="0" float="true" pos="590,191,0,0" width="150" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_50" text="2" float="true" pos="672,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_101" text="5" float="true" pos="672,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_104" text="8" float="true" pos="672,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_99" text="3" float="true" pos="755,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_102" text="6" float="true" pos="755,67,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_105" text="9" float="true" pos="755,129,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="btn_110" text="." float="true" pos="755,191,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="rbtn_8" text="Back" float="true" pos="872,5,0,0" width="70" height="55" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
        <Button name="rbtn_13" text="Enter" float="true" pos="872,67,0,0" width="70" height="117" bkcolor="#FF302F37" textcolor="#00FFFFFF" pushedtextcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" pushedimage="pushed.png" />
      </VerticalLayout>
    </TabLayout>
   
  </VerticalLayout>
</Window>

技术关键点

#include "VKFrame.h"
#include "shellapi.h"
#pragma comment(lib, "shell32.lib")

CVKFrame::CVKFrame()
{
	m_pMinBtn  = NULL;
	m_pCloseBtn = NULL;
	m_pTabLayout = NULL;
	m_pSymbolTab = NULL;
	m_pLShift = NULL;
	m_pRShift = NULL;
	m_pNum    = NULL;
	m_pCtrl   = NULL;
	m_pLSymbol = NULL;
	m_pRSymbol = NULL;
	m_pInputBtn = NULL;
	m_bShiftDown = false;
	m_bCtrlDown = false;
}
CVKFrame::~CVKFrame(void)
{
}

void CVKFrame::OnFinalMessage(HWND /*hWnd*/) 
{ 	
	delete this; 
}
void CVKFrame::LoadCom()
{
}
void CVKFrame::OnPrepare()
{
}
void CVKFrame::Init()
{
	m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
	m_pCloseBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn")));
	m_pTabLayout = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("switch")));
	m_pLShift   = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_shiftl")));
	m_pRShift   = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_shiftr")));
	m_pNum   = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_num")));
	m_pCtrl   = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_ctrl")));
	m_pSymbolTab = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("sswitch")));
	m_pLSymbol = static_cast<CButtonUI*>(m_pm.FindControl(_T("lsymbol")));
	m_pRSymbol = static_cast<CButtonUI*>(m_pm.FindControl(_T("rsymbol")));
	m_pInputBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("inputtype")));
	for(int i=65;i<91;i++)
	{
		CStdString strTemp;
		strTemp.Format(_T("btn_%d"), i);
		CButtonUI *pBtn = static_cast<CButtonUI*>(m_pm.FindControl(strTemp.GetData()));
		if(pBtn)
		{
			CStdString str = pBtn->GetText();
			m_pVecBtn.push_back(pBtn);
		}
	}
}
void CVKFrame::Notify(TNotifyUI& msg)
{
	if( msg.sType == _T("windowinit") ) OnPrepare();
	else if( msg.sType == _T("click") )
	{
		if( msg.pSender == m_pCloseBtn )
		{
			PostQuitMessage(0);
			return; 
		}
		else if( msg.pSender == m_pMinBtn )
		{ 
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); 
			return;
		}
		else if(msg.pSender->GetName() == _T("handinput"))
		{
			CStdString strapp = CPaintManagerUI::GetInstancePath() + _T("..\\app\\handinput\\handinput.exe");	
			ShellExecute(NULL, _T("open"), strapp.GetData(), NULL, NULL, SW_SHOWDEFAULT );
			//	PostQuitMessage(0);
		}
		else if(msg.pSender == m_pCtrl)  //ctrl键
		{
			if(m_pCtrl->IsSelected())
			{
				m_bCtrlDown = false;
				m_pLShift->SetEnabled();
				m_pRShift->SetEnabled();
			}
			else
			{
				m_bCtrlDown = true;
				m_pLShift->Selected(false);
				m_pRShift->Selected(false);
				m_pLShift->SetEnabled(false);
				m_pRShift->SetEnabled(false);
			}
		}
		
		else if( msg.pSender == m_pLSymbol ) //符号左方向按钮
		{ 
			if(m_pSymbolTab)
				m_pSymbolTab->SelectItem(0);
			if(m_pLSymbol && m_pRSymbol)
			{
				m_pLSymbol->SetEnabled(false);
				m_pRSymbol->SetEnabled();
			}
		}
		else if( msg.pSender == m_pRSymbol ) //符号右方向按钮
		{ 
			if(m_pSymbolTab)
				m_pSymbolTab->SelectItem(1);
			if(m_pLSymbol && m_pRSymbol)
			{
				m_pLSymbol->SetEnabled();
				m_pRSymbol->SetEnabled(false);
			}
		}
		else if(msg.pSender->GetName().Find(_T("btn_")) == 0) //普通按键
		{
			CStdString strTemp = msg.pSender->GetName();
			strTemp = strTemp.Right(strTemp.GetLength() - 4);
			int iKey = _wtoi(strTemp.GetData());
			OnClickVK(iKey);
		}
		else if(msg.pSender->GetName().Find(_T("lbtn_")) == 0 || msg.pSender->GetName().Find(_T("rbtn_")) == 0) //左右都有的按键
		{
			CStdString strTemp = msg.pSender->GetName();
			strTemp = strTemp.Right(strTemp.GetLength() - 5);
			int iKey = _wtoi(strTemp.GetData());
			OnClickVK(iKey);
		}
		else if(msg.pSender->GetName().Find(_T("opt_shift")) == 0) //shift键
		{
			if(msg.pSender == m_pLShift)
			{
				if(m_pLShift->IsSelected())
				{
					m_pRShift->Selected(false);
					SwitchLetter(false);
					m_bShiftDown = false;
				}
				else
				{
					m_pRShift->Selected(true);
					SwitchLetter();
					m_bShiftDown = true;
				}
			}
			else
			{
				if(m_pRShift->IsSelected())
				{
					m_pLShift->Selected(false);
					SwitchLetter(false);
					m_bShiftDown = false;
				}
				else
				{
					m_pLShift->Selected(true);
					SwitchLetter();
					m_bShiftDown = true;
				}
			}
		}
		else if(msg.pSender == m_pNum) //数字键
		{
			if(m_pNum->IsSelected())
			{
				m_pTabLayout->SelectItem(0);
				m_pCtrl->SetEnabled(true);

				m_pLShift->Selected(false);
				m_pRShift->Selected(false);
				SwitchLetter(false);
				m_bShiftDown = false;
			}
			else
			{
				m_bShiftDown = false;
				m_pTabLayout->SelectItem(1);
				m_pLShift->Selected(true);
				m_pRShift->Selected(true);
				m_pLShift->SetEnabled(true);
				m_pRShift->SetEnabled(true);
				m_pCtrl->Selected(false);
				m_pCtrl->SetEnabled(false);
			}
		}
		else if(msg.pSender->GetName().Find(_T("symbol_")) == 0) //符号键
		{
			CStdString strTemp = msg.pSender->GetName();
			strTemp = strTemp.Right(strTemp.GetLength() - 7);
			int iKey = _wtoi(strTemp.GetData());
			keybd_event(VK_SHIFT,0,0,0);
			keybd_event(iKey,0,0,0);
			keybd_event( iKey, 0, KEYEVENTF_KEYUP, 0); 
			keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
		}
	}
}

LRESULT CVKFrame::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	LONG styleValue = ::GetWindowLong(*this, GWL_EXSTYLE);
	styleValue &= ~WS_CAPTION;
	::SetWindowLong(*this, GWL_EXSTYLE, styleValue | WS_EX_NOACTIVATE);

	SetWindowPos(*this, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

	m_pm.Init(m_hWnd);
	CDialogBuilder builder;
	CControlUI* pRoot = builder.Create(_T("keyboard.xml"), (UINT)0,  NULL, &m_pm);
	ASSERT(pRoot && "Failed to parse XML");
	m_pm.AttachDialog(pRoot);
	m_pm.AddNotifier(this);

	Init();

	m_WndShadow.Create(m_hWnd);
	m_WndShadow.SetSize(4);
	m_WndShadow.SetPosition(0, 0);

	return 0;
}

LRESULT CVKFrame::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	::PostQuitMessage(0L);

	bHandled = FALSE;
	return 0;
}

LRESULT CVKFrame::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if( ::IsIconic(*this) ) bHandled = FALSE;
	return (wParam == 0) ? TRUE : FALSE;
}
LRESULT CVKFrame::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	return 0;
}
LRESULT CVKFrame::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	return 0;
}
LRESULT CVKFrame::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
	::ScreenToClient(*this, &pt);

	RECT rcClient;
	::GetClientRect(*this, &rcClient);

	RECT rcCaption = m_pm.GetCaptionRect();
	if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
		&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) {
			CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
			if( pControl && _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0 )
				return HTCAPTION;
	}

	return HTCLIENT;
}

LRESULT CVKFrame::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if(!IsIconic(*this))   
	{  
		RECT rcClient;  
		GetClientRect(*this, &rcClient);  
		HRGN hRgn = ::CreateRoundRectRgn(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, 3, 3);  
		SetWindowRgn(*this, hRgn, TRUE);  
		DeleteObject(hRgn);  
	}  
	bHandled = FALSE;
	return 0;
}

LRESULT CVKFrame::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	bHandled = FALSE;
	return 0;
}
LRESULT CVKFrame::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	LRESULT lRes = 0;
	BOOL bHandled = TRUE;
	switch( uMsg ) 
	{
	case WM_CREATE:        lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
	case WM_DESTROY:       lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
	case WM_NCACTIVATE:    lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
	case WM_NCCALCSIZE:    lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
	case WM_NCPAINT:       lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
	case WM_NCHITTEST:     lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
	case WM_SIZE:          lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
	default:
		bHandled = FALSE;
	}
	SetCursor(LoadCursor(NULL, IDC_ARROW));
	if( bHandled ) 
		return lRes;
	if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) 
		return lRes;
	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}

void CVKFrame::OnClickVK(int iKeyValue)
{
	if(m_bCtrlDown && (iKeyValue == 65 || iKeyValue == 67 || iKeyValue == 86 || iKeyValue == 88 || iKeyValue == 90) )
	{
		keybd_event(VK_CONTROL,0,0,0);
	}
	if(m_bShiftDown)
		keybd_event(VK_SHIFT,0,0,0);
	keybd_event( iKeyValue, 0, 0, 0); 
	Sleep(50); 
	
	keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
	
	m_pCtrl->Selected(false);
	m_bCtrlDown = false;
}
void CVKFrame::SwitchLetter(bool bUpper)
{
	
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值