api question part2

new topic     » topic index » view thread      » older message » newer message

--0-1974550146-1023447491=:8356


Hi all,

Sorry, for my revious email on the issue, here is a bit more of what i
wantedto mean.

I've created a window with a multi-part statusbar. I want to place
a bitmap in the second part of the status Bar. This is what i do

--** Below are code snippets from my program to help u understand the problem

---------------------------------------------------------
--Function: CreateStatusBar(integer parent)
--Use     : This Function creates a status bar for the specified window
--Return  :It returnsthe handle of the status window
---------------------------------------------------------

global function CreateStatusBar(atom parent) 
atom ctrl   
ctrl = CreateWindow(NULL,STATUSCLASSNAME,"",WS_VISIBLE+WS_CHILD+3,
    0,0,0,0,parent,NULL,NULL)
   return ctrl
end function 

---------------------------------------------------------
--Procedure: setSubFields(atom parant,parts,sequence pData)
--Use      :It sets different parts to a status Window
--         :parts is numbaer of parts and pData is the sequence of 
--         :for each element
---------------------------------------------------------  

global procedure setSubFields(atom parent,integer parts,sequence pData)  
integer len_,pointer
atom mem_loc,struc_len,x 
sequence rect
len_     = length(pData)
if len_ != parts then
wait_abort("length of pData should equal numer of parts")
end if   
struc_len=parts*4  
pointer  = 1  
mem_loc  = get_mem(0,struc_len)
for i    = 0 to (struc_len-4) by 4 do
x =  pData[pointer]
if x<1 and x>0 then
rect = getRect(parent)  
x    = floor(rect[3]*x)  
end if
poke4(mem_loc+i,x)  
pointer += 1
end for   
len_     = sendMessage(parent,SB_SETPARTS,parts,mem_loc)
end procedure    

---------------------------------------------------------
--Procedure: setStatusText(id,part,text)
--Use      :Use this function to set text to a status bar item
--         :use 1 for part if you have a simple status bar
---------------------------------------------------------   

global procedure setStatusText(atom id,integer part,object text)  
atom ret,block
if atom(text) then
text = sprintf("%g",text)
end if  
block = get_block()
text  = get_mem(block,text) 
if part >0 then part-=1 end if
ret  = sendMessage(id,SB_SETTEXTA,part,text)
if ret = NULL then
wait_abort("Failed to setText in SetStatusText")
end if
free_block(block)
end procedure     

---------------------------------------------------------
--Function: getStatusText(atom id,integer part)
--Use     :It retrieves text from a Status Bar. If the Status
--        :bar is a simple one then simply use getWindowText(id)
--        : or use this function but with part as 0
--Return  :Itreturns text from the specified part of a text bar
---------------------------------------------------------  

global function getStatusText(atom id,integer part)
integer len_,mem_stack,buffer_loc,retval
sequence str  
if part >0 then part-=1 end if
len_ = sendMessage(id,SB_GETTEXTLENGTHA,part,0) 
len_ = LOWORD(len_)  
mem_stack = get_block()
buffer_loc= get_mem(mem_stack,len_)  
retval = sendMessage(id,SB_GETTEXTA,part,buffer_loc)
if LOWORD(retval) != len_ then
wait_abort("getStatusText Failed")
end if
str = peek_string(buffer_loc)
free_block(mem_stack)
   return str
end function   

---------------------------------------------------------
--Function: Custom_Status(parent)
--Use     :This is my custom made status window.
--Return  :It returns the handle of the new created Wnd
--------------------------------------------------------- 

global function Custom_Status(atom parent) 
atom status_id,art  
status_id = CreateStatusBar(parent) 
setSubFields(status_id,4,{140,200,260,380}) 

--#####   --Areas of Concern (The lparam of the SB_SETTEXTA message)
--####    --According to help file,this parameter represents 32 bits of data 
--###     --Qn. What do they mean 32bits of Data?, Do they mean the call_back()
--##      --From a separate procedure handling the Status Window?
art       =
sendMessage(status_id,SB_SETTEXTA,SBT_OWNERDRAW+2,loadBitmap("c:\\full\\conn1.bmp"))
--The above msg specifies an owner drawn status Window at part 3
--since the parts are zero -index based. 
--loadBitmap is just a wrap up of loadImageA C function for IMAGE_BITMAP
--####

if art = NULL then
wait_abort("Failed")
end if
return  status_id
end function 

global constant img = loadBitmap("c:\\full\\conn1.bmp")

The above functions are used for creating the Status bar, and making it owner
drawn through the WM_DRAWITEM message in the Window Procedure.
Anyway this is what i do in the WndProc of my program

if iMsg    = WM_CREATE then  
statuswnd  = Custom_Status(hwnd)
elsif iMsg = WM_SIZE  then 
if c_func(zIsWindow,{statuswnd}) then
status_retval = sendMessage(statuswnd,iMsg,wParam,lParam)
setSubFields(statuswnd,5,{.5,.6,.7,.8,.9})   
end if 
elsif iMsg = WM_DRAWITEM then
c_proc(zUpdateWindow, {hwnd})
childwnd_id= peek4u(lParam+4 ) 
part       = peek4u(lParam+8 ) 
wnd_hwnd   = peek4u(lParam+20) 
hdc        = peek4u(lParam+24) 
rcItem     = peek4u(lParam+28) 
bit        = peek4u(lParam+32) 

bitdc      = c_func(zCreateCompatibleDC,{hdc})
bit        = c_func(zSelectObject,{bitdc,img}) 
part       = c_func(zBitBlt,{hdc,rcItem,3,32,32,bitdc,0,0,#CC0020})
releaseDC(statuswnd,hdc)  
return 0

 

The above draws the bitmap but during WM_SIZE the image disappears.
Should i also place these routines in WM_SIZE,or WM_PAINT? I thought WM_DRAWITEM
was
supposed to handle all these

If possible could some one give me source code to how to overcome this
problem.Please
focus your answers on API

Incase all the above routines are gibberish! then do me a favor by sending me
code
that will keep the image on the status bar even if i'm resizing! Thx in
advance(User
drawn Status bar)

Thanx Jordah Ferguson
jorfergie03 at yahoo.com



---------------------------------
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup
--0-1974550146-1023447491=:8356
Content-Type: text/html; charset=us-ascii

<P>Hi all,</P>
<P>Sorry, for my revious email on the issue, here is a bit more of what
i<BR>wantedto mean.</P>
<P>I've created a window with a multi-part statusbar. I want to place<BR>a
bitmap in the second part of the status Bar. This is what i do</P>
<P>--** Below are code snippets from my program to help u understand the
problem</P>
<P>---------------------------------------------------------<BR>--Function:
CreateStatusBar(integer parent)<BR>--Use&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;This
Function creates a status bar for the specified window<BR>--Return&nbsp; :It
returnsthe handle of the status
window<BR>---------------------------------------------------------</P>
<P>global function CreateStatusBar(atom parent) <BR>atom ctrl&nbsp;&nbsp;
<BR>ctrl =
CreateWindow(NULL,STATUSCLASSNAME,"",WS_VISIBLE+WS_CHILD+3,<BR>&nbsp;&nbsp;&nbsp;
0,0,0,0,parent,NULL,NULL)<BR>&nbsp;&nbsp; return ctrl<BR>end function&nbsp;</P>
<P>---------------------------------------------------------<BR>--Procedure:
setSubFields(atom parant,parts,sequence
pData)<BR>--Use&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :It sets different parts to a
status Window<BR>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :parts is
numbaer of parts and pData is the sequence of
<BR>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :for each
element<BR>---------------------------------------------------------&nbsp; </P>
<P>global procedure setSubFields(atom parent,integer parts,sequence pData)&nbsp;
<BR>integer len_,pointer<BR>atom mem_loc,struc_len,x <BR>sequence
rect<BR>len_&nbsp;&nbsp;&nbsp;&nbsp; = length(pData)<BR>if len_&nbsp;!= parts
then<BR>wait_abort("length of pData should equal numer of parts")<BR>end
if&nbsp;&nbsp; <BR>struc_len=parts*4&nbsp; <BR>pointer&nbsp; = 1&nbsp;
<BR>mem_loc&nbsp; = get_mem(0,struc_len)<BR>for i&nbsp;&nbsp;&nbsp; = 0 to
(struc_len-4) by 4 do<BR>x =&nbsp; pData[pointer]<BR>if x&lt;1 and x&gt;0
then<BR>rect = getRect(parent)&nbsp; <BR>x&nbsp;&nbsp;&nbsp; =
floor(rect[3]*x)&nbsp;&nbsp;<BR>end if<BR>poke4(mem_loc+i,x)&nbsp; <BR>pointer +=
1<BR>end for&nbsp;&nbsp; <BR>len_&nbsp;&nbsp;&nbsp;&nbsp; =
sendMessage(parent,SB_SETPARTS,parts,mem_loc)<BR>end procedure&nbsp;&nbsp;&nbsp;
</P>
<P>---------------------------------------------------------<BR>--Procedure:
setStatusText(id,part,text)<BR>--Use&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :Use this
function to set text to a status bar
item<BR>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :use 1 for part if you
have a simple status
bar<BR>---------------------------------------------------------&nbsp;&nbsp; </P>
<P>global procedure setStatusText(atom id,integer part,object text)&nbsp;
<BR>atom ret,block<BR>if atom(text) then<BR>text = sprintf("%g",text)<BR>end
if&nbsp;&nbsp;<BR>block = get_block()<BR>text&nbsp; =
get_mem(block,text)&nbsp;<BR>if part &gt;0 then part-=1 end if<BR>ret&nbsp; =
sendMessage(id,SB_SETTEXTA,part,text)<BR>if ret = NULL then<BR>wait_abort("Failed
to setText in SetStatusText")<BR>end if<BR>free_block(block)<BR>end
procedure&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>---------------------------------------------------------<BR>--Function:
getStatusText(atom id,integer part)<BR>--Use&nbsp;&nbsp;&nbsp;&nbsp; :It
retrieves text from a Status Bar. If the
Status<BR>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :bar is a simple one then
simply use getWindowText(id)<BR>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : or
use this function but with part as 0<BR>--Return&nbsp; :Itreturns text from the
specified part of a text
bar<BR>---------------------------------------------------------&nbsp; </P>
<P>global function getStatusText(atom id,integer part)<BR>integer
len_,mem_stack,buffer_loc,retval<BR>sequence str&nbsp; <BR>if part &gt;0 then
part-=1 end if<BR>len_ = sendMessage(id,SB_GETTEXTLENGTHA,part,0)&nbsp;<BR>len_ =
LOWORD(len_)&nbsp; <BR>mem_stack = get_block()<BR>buffer_loc=
get_mem(mem_stack,len_)&nbsp;&nbsp;<BR>retval =
sendMessage(id,SB_GETTEXTA,part,buffer_loc)<BR>if LOWORD(retval) != len_
then<BR>wait_abort("getStatusText Failed")<BR>end if<BR>str =
peek_string(buffer_loc)<BR>free_block(mem_stack)<BR>&nbsp;&nbsp; return
str<BR>end function&nbsp;&nbsp; </P>
<P>---------------------------------------------------------<BR>--Function:
Custom_Status(parent)<BR>--Use&nbsp;&nbsp;&nbsp;&nbsp; :This is my custom made
status window.<BR>--Return&nbsp; :It returns the handle of the new created
Wnd<BR>--------------------------------------------------------- </P>
<P>global function Custom_Status(atom parent)&nbsp;<BR>atom status_id,art&nbsp;
<BR>status_id = CreateStatusBar(parent)
<BR>setSubFields(status_id,4,{140,200,260,380})&nbsp;</P>
<P>--#####&nbsp;&nbsp; --Areas of Concern (The lparam of the SB_SETTEXTA
message)<BR>--####&nbsp;&nbsp;&nbsp; --According to help file,this parameter
represents 32 bits of data <BR>--###&nbsp;&nbsp;&nbsp;&nbsp; --Qn. What do they
mean 32bits of Data?, Do they mean the
call_back()<BR>--##&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --From a separate procedure
handling the Status Window?<BR>art&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
sendMessage(status_id,SB_SETTEXTA,SBT_OWNERDRAW+2,loadBitmap("c:\\full\\conn1.bmp"))<BR>--The
above msg specifies an owner drawn status Window at part 3<BR>--since the parts
are zero -index based. <BR>--loadBitmap is just a wrap up of loadImageA C
function for IMAGE_BITMAP<BR>--####</P>
<P>if art = NULL then<BR>wait_abort("Failed")<BR>end if<BR>return&nbsp;
status_id<BR>end function </P>
<P>global constant img = loadBitmap("c:\\full\\conn1.bmp")</P>
<P>The above functions are used for creating the Status bar, and making it
owner<BR>drawn through the WM_DRAWITEM message in the Window Procedure.<BR>Anyway
this is what i do in the WndProc of my program</P>
<P>if iMsg&nbsp;&nbsp;&nbsp; = WM_CREATE then&nbsp; <BR>statuswnd&nbsp; =
Custom_Status(hwnd)<BR>elsif iMsg = WM_SIZE&nbsp; then&nbsp;<BR>if
c_func(zIsWindow,{statuswnd}) then<BR>status_retval =
sendMessage(statuswnd,iMsg,wParam,lParam)<BR>setSubFields(statuswnd,5,{.5,.6,.7,.8,.9})&nbsp;&nbsp;
<BR>end if <BR>elsif iMsg = WM_DRAWITEM then<BR>c_proc(zUpdateWindow,
{hwnd})<BR>childwnd_id= peek4u(lParam+4 )
<BR>part&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = peek4u(lParam+8 )
<BR>wnd_hwnd&nbsp;&nbsp; =
peek4u(lParam+20)&nbsp;<BR>hdc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
peek4u(lParam+24) <BR>rcItem&nbsp;&nbsp;&nbsp;&nbsp; =
peek4u(lParam+28)&nbsp;<BR>bit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
peek4u(lParam+32)&nbsp;</P>
<P>bitdc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
c_func(zCreateCompatibleDC,{hdc})<BR>bit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
=
c_func(zSelectObject,{bitdc,img})&nbsp;<BR>part&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
=
c_func(zBitBlt,{hdc,rcItem,3,32,32,bitdc,0,0,#CC0020})<BR>releaseDC(statuswnd,hdc)&nbsp;
<BR>return 0</P>
<P>&nbsp;</P>
<P>The above draws the bitmap but during WM_SIZE the image disappears.<BR>Should
i also place these routines in WM_SIZE,or WM_PAINT? I thought WM_DRAWITEM
was<BR>supposed to handle all these</P>
<P>If possible could some one give me source code to how to overcome this
problem.Please<BR>focus your answers on API</P>
<P>Incase all the above routines are gibberish! then do me a favor by sending me
code<BR>that will keep the image on the status bar even if i'm resizing! Thx in
advance(User<BR>drawn Status bar)</P>
<P>Thanx Jordah Ferguson<BR><A href="mailto:jorfergie03 at
yahoo.com">jorfergie03 at yahoo.com</A></P><p><br><hr size=1><b>Do You
Yahoo!?</b><br>
<a
href="http://rd.yahoo.com/welcome/*http://fifaworldcup.yahoo.com/fc/en/spl">Sign-up
for Video Highlights</a> of 2002 FIFA World Cup
--0-1974550146-1023447491=:8356--

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu