forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


problem with api-call

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Fri Nov 03, 2006 10:32 am    Post subject: problem with api-call Reply with quote

hi,

i'm trying to evaluate the text of an item in a listbox using LB_GETTEXT.
in the api-helpfile it is message-number $0189, but it always returns the number of characters like LB_GETTEXTLEN ($018A) does. either the message-number is not correct or i'm doing something wrong.

here is a code-snippet:


Code:



:timer

  %X = @diff(@mousepos(X),@winpos(~list1,L))
  %Y = @diff(@mousepos(Y),@winpos(~list1,T))

            #        LB_ITEMFROMPOINT                 
  %%index = @sendmsg(~LIST1,$01A9,0,@makelparam(%X,%Y))

  if @not(@greater(%%index,@count(list1)))
                #        LB_GETTEXTLEN         

    %%TextLen = @sendmsg(~LIST1,$018A,%%index,0)
 
             #        LB_GETTEXT                             
    %%item = @sendmsg(~LIST1,$0189,%%index,@STRBUF(@succ(%%TextLen)))

    dialog set,text,Item: %%index - %%item

   else
    dialog set,text,Item:
  end

  goto evloop





functions:


Code:



:MakeLPARAM

  %R = @fmul(%2,65536)
  %R = @fadd(%R,%1)

 exit %R


:strbuf

  if %1
    %S = @fill(%1)@chr(0)
   else
    %S = @fill(256)@chr(0)
  end
  %R = @addr("%S")

 exit %R





would be great, if someone of you could help me.
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Nov 03, 2006 2:08 pm    Post subject: Reply with quote

The message is working correctly. According to MSDN the result is the length of the returned string, in chars. LParam is a pointer to the buffer that will receive the string.

What you need to do is use @FILL to create a string %S long enough to hold the string, and then pass its address in the LParam argument using @ADDR("%S").

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Fri Nov 03, 2006 2:55 pm    Post subject: Reply with quote

thank you jules,

i just found out by myself wat's wrong.
i expected the string in the returnvalue, not in the buffer itself. sometimes i'm sitting with my ass on my eyes Embarassed

so now it is:


Code:


 #               LB_GETTEXT                                   
    %i = @fill(@sum(%%TextLen,2))
    %%item = @sendmsg(~LIST1,$0189,%%index,@addr("%i"))

    %%item = %i

Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Nov 03, 2006 4:25 pm    Post subject: Reply with quote

It would be easier to use:
Code:

%%item = @item(LIST1,%%index)

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Fri Nov 03, 2006 5:29 pm    Post subject: Reply with quote

of course, but then the item gets selected.
this routine is for a tooltip on single listboxitems and no clickevent
should be generated.

greetings

attreus
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Nov 03, 2006 5:34 pm    Post subject: Reply with quote

Ah, I see.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Fri Nov 03, 2006 8:25 pm    Post subject: Reply with quote

By the way - what does your code do? Gives a tip event based on which list item the cursor is near? If so, I didn't know VDS could do that, even using API calls.
_________________
Joe Floyd
Back to top
View user's profile Send private message
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Fri Nov 03, 2006 10:09 pm    Post subject: working example of tooltip on listbox-items Reply with quote

.
here is a working example, i hope some of you will find it useful too:

Code:


Title ToolTipTest by attreus

#define Function,Wrap
#define Function,MakeLPARAM
#define Command,ToolTip

option decimalsep,"."

  DIALOG CREATE,New Dialog,-1,0,240,170,class ToolTipTest,notitle
  dialog add,TEXT,Text,140,20,,,Index:
  DIALOG ADD,LIST,LIST1,20,20,200,100,,click,dblclick
  dialog add,button,exit,136,170,50,22,Exit
  DIALOG SHOW
 
  list loadtext,list1
"Bitte laut sprechen....
"
"Englisch für Anfänger:
"
"... Drei Hexen schauen sich drei Swatch Uhren an. Welche Hexe schaut welche Swatch Uhr an?
"
"Und nun das Ganze in englischer Sprache!
"
"... Three witches watch three swatch watches. Which witch watches which swatch watch?
"
"
"Englisch für Fortgeschrittene:
"
"... Drei geschlechtsumgewandelte Hexen schauen sich drei Swatch Uhrenknöpfe an. Welche geschlechtsumgewandelte Hexe schaut sich welchen Swatch Uhrenknopf an?
"
"...das Ganze wieder in englischer Sprache !
"
"... Three switched witches watch three Swatch watch switches. Which switched witch watches which Swatch watch switch?
"
"
"Englisch im Endstadium:
"
"Drei Schweizer Hexen-Schlampen, die sich wünschen geschlechtsumgewandelt zu sein, schauen sich schweizer Swatch Uhrenknöpfe an. Welche schweizer Hexen-Schlampe, die sich wünscht geschlechtsumgewandelt zu sein, schaut sich welche schweizer Swatch Uhrenknöpfe an?
"
"...das ganze in Englisch:
"
"... Three swiss witch-bitches, which wished to be switched swiss witch-bitches, wish to watch three swiss Swatch watch switches. Which swiss witch-oops which wishes to be a switched swiss witch-oops, wishes to watch which swiss Swatch watch switch?

  %%List1 = @winexists(~List1)

:Evloop
  wait event,0.1
  goto @event()
 
:timer

  %X = @diff(@mousepos(X),@winpos(%%List1,L))
  %Y = @diff(@mousepos(Y),@winpos(%%List1,T))

            #        LB_ITEMFROMPOINT                 
  %%LPARAM = @makelparam(%X,%Y)
  %%index = @sendmsg(%%List1,$01A9,0,%%LPARAM)
 
  if @not(@greater(%%index,@count(List1)))

                #        LB_GETTEXTLEN         
    %%TextLen = @sendmsg(%%List1,$018A,%%index,0)
 
             #        LB_GETTEXT                       
    %I = @fill(@sum(%%TextLen,2))
    %%item = @sendmsg(%%List1,$0189,%%index,@addr("%I"))

    %%item = %I
    if @greater(@len(%%item),38)
      tooltip %%item,@mousepos(x),@mousepos(y)
    end
    dialog set,text,Index: %%index
   else
    dialog set,text,Index:
  end

  goto evloop

:list1dblClick
  info DoubleClick
  goto evloop

:list1Click
   wait 0.1
   if @equal(@event(),list1dblClick)
     goto list1dblClick
   end
   info SingleClick
  goto evloop

:exitbutton 
:Close
  exit

#                                                                                         
#     Function MakeLPARAM                                                                 
#                                                                                         

:MakeLPARAM

  %R = @prod(%2,65536)
  %R = @sum(%R,%1)

 exit %R

#                                                                                         
#     Command ToolTip                                                                     
#                                                                                         

:ToolTip

  %%ToolTip_Text = @wrap(%1,70)
  %%ToolTip_X = @diff(%2,-10)
  %%ToolTip_Y = @diff(%3,-10)
  %%ToolTip_Duration = 50
  %%ToolTip_Exit =
  %%ToolTip_Pixels_V = 14
  %%ToolTip_Pixels_H = 26

  DIALOG CREATE,ToolTip,%%ToolTip_Y,%%ToolTip_X,360,60,NOTITLE,INVISIBLE,CLASS ToolTip,ONTOP,NOSYS
  DIALOG ADD,STYLE,normal,Tahoma,,L,,

  #     Evaluate height and width of the wrapped text           
  DIALOG ADD,TEXT,text,25,32,,,%%ToolTip_Text,,normal,TRANSPARENT
  %%ToolTip_TextHeight = @dlgpos(text,H)
  %%ToolTip_TextWidth =  @dlgpos(text,W)
  DIALOG REMOVE,text

  DIALOG SETPOS,,,,@fadd(%%ToolTip_TextWidth,%%ToolTip_Pixels_v),@fadd(%%ToolTip_TextHeight,%%ToolTip_Pixels_V)

  DIALOG ADD,SHAPE,left,0,0,40,@fadd(%%ToolTip_TextHeight,%%ToolTip_Pixels_V),E8F5FF,BLACK,,ROUNDRECT,click
  DIALOG ADD,SHAPE,right,0,@fsub(%%ToolTip_TextWidth,%%ToolTip_Pixels_H),40,@fadd(%%ToolTip_TextHeight,%%ToolTip_Pixels_V),E8F5FF,BLACK,,ROUNDRECT,click
  DIALOG ADD,SHAPE,center,0,22,@fsub(%%ToolTip_TextWidth,%%ToolTip_Pixels_H),@fadd(%%ToolTip_TextHeight,%%ToolTip_Pixels_V),E8F5FF,BLACK,,RECTANGLE,click
  DIALOG ADD,SHAPE,middle,1,22,@fsub(%%ToolTip_TextWidth,%%ToolTip_Pixels_H),@fadd(%%ToolTip_TextHeight,@diff(%%ToolTip_Pixels_V,2)),E8F5FF,E8F5FF,,RECTANGLE,click

  DIALOG ADD,TEXT,text,6,8,,,%%ToolTip_Text,,normal,TRANSPARENT,click

  DIALOG SHOW

  %C = 1

  repeat
    wait event,0.3
    %X = @diff(@mousepos(X),@winpos(%%List1,L))
    %Y = @diff(@mousepos(Y),@winpos(%%List1,T))
    %%LPARAM = @makelparam(%X,%Y)
    %%NewIndex = @sendmsg(%%List1,$01A9,0,%%LPARAM)
    if @not(@equal(%%NewIndex,%%index)) @equal(@strdel(@event(),1,-5),click) @greater(%C,%%ToolTip_Duration)
      %%ToolTip_Exit = 1
    end
  until %%ToolTip_Exit
   
    dialog close
    %A = @event()
    wait event,0.01
    %A = @event()
  exit

#                                                                                         
#     Function Wrap                                                                       
#                                                                                         

:Wrap

  if @not(%1)
    exit
  end

  if @not(%2)
    exit ERROR
  end

  %%Wrap_String = %1
  %%Wrap_Max_Length = %2

  if @not(@numeric(%2)) @equal(%3,number) @equal(%2,",")
    %%Wrap_Break_Sign = @substr(%2,1)
    goto BreakSign
  end

  if @equal(%3,exact)
    goto BreakExact
  end

#              Begin of the norrmal wrap-routine                                         

    Repeat
      %%Wrap_Counter = %%Wrap_Max_Length
      Repeat
       if @greater(%%Wrap_Max_Length,@len(%%Wrap_string))
         %%Wrap_Finish = 1
       end    
        %%Wrap_Character = @substr(%%Wrap_String,%%Wrap_Counter)
      If @equal(%%Wrap_Character,@chr(32)) @equal(%%Wrap_Character,".") @equal(%%Wrap_Character,",") @equal(%%Wrap_Character,";") @equal(%%Wrap_Character,"-") @equal(%%Wrap_Character,"!") @equal(%%Wrap_Character,"?") @equal(%%Wrap_Character,":")
        %%Wrap_Ok = 1
        %%Wrap_New = %%Wrap_New@substr(%%Wrap_String,1,%%Wrap_Counter)@cr()
        %%Wrap_String = @substr(%%Wrap_String,@succ(%%Wrap_Counter),@len(%%Wrap_String))       
       else
        %%Wrap_Counter = @pred(%%Wrap_Counter)
        %%Wrap_Ok =
        #    forced-routine       
        if @equal(%%Wrap_Counter,0)
          if @equal(%3,forced)
           %%Wrap_String = @strins(%%Wrap_String,%%Wrap_max_length,@chr(32))
           %%Wrap_Ok = 1
          else
           %%Wrap_Finish = 1
           %%Wrap_Counter = @len(%1)
         end
        end
       end   
      Until %%Wrap_Ok %%Wrap_Finish
    Until %%Wrap_Finish
    %%Wrap_New = %%Wrap_New@substr(%%Wrap_String,1,%%Wrap_Counter)
    %R = @trim(%%Wrap_New)
  goto end

#              Begin of the wrap-routine with spezified character                         
:BreakSign

    repeat
      %%Wrap_Counter = 1
      Repeat
        %%Wrap_Character = @substr(%%Wrap_String,%%Wrap_Counter)
          if @equal(%%Wrap_Counter,@len(%%Wrap_String))
            %%wrap_finish = 1
          end
          If @equal(%%Wrap_Character,%%Wrap_Break_Sign)
           %%Wrap_Ok = 1
            %%Wrap_New = %%Wrap_New@substr(%%Wrap_String,1,%%Wrap_Counter)@cr()
            %%Wrap_String = @substr(%%Wrap_String,@succ(%%Wrap_Counter),@len(%%Wrap_String))
         else
          %%Wrap_Counter = @succ(%%Wrap_Counter)
          %%Wrap_Ok =
         End

      Until %%Wrap_Ok %%wrap_finish
    Until %%wrap_finish
    %%Wrap_New = %%Wrap_New@substr(%%Wrap_String,1,%%Wrap_Counter)

    %R = @trim(%%Wrap_New)
  goto end

#              Begin of the exact wrap-routine                                           
:BreakExact

    %%Wrap_Counter = 1
    %%Wrap_String =
    REPEAT
      %%Wrap_String = %%Wrap_String@substr(%1,%%Wrap_Counter)
      if @equal(@mod(%%Wrap_Counter,%%Wrap_Max_Length),0)
        %%Wrap_String = %%Wrap_String@cr()
      end
      %%Wrap_Counter = @succ(%%Wrap_Counter)
    UNTIL @greater(%%Wrap_Counter,@len(%1))
 
    %R = @trim(%%Wrap_String)

:end
  %%Wrap_Ok =
  %%wrap_finish =
  %%Wrap_New =

 exit %R




thanks to all of you in this forum for de code-snippets and hints to make this work.

attreus
.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group