api question part2
- Posted by jordah ferguson <jorfergie03 at yahoo.com> Jun 07, 2002
- 486 views
--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 : This Function creates a status bar for the specified window<BR>--Return :It returnsthe handle of the status window<BR>---------------------------------------------------------</P> <P>global function CreateStatusBar(atom parent) <BR>atom ctrl <BR>ctrl = CreateWindow(NULL,STATUSCLASSNAME,"",WS_VISIBLE+WS_CHILD+3,<BR> 0,0,0,0,parent,NULL,NULL)<BR> return ctrl<BR>end function </P> <P>---------------------------------------------------------<BR>--Procedure: setSubFields(atom parant,parts,sequence pData)<BR>--Use :It sets different parts to a status Window<BR>-- :parts is numbaer of parts and pData is the sequence of <BR>-- :for each element<BR>--------------------------------------------------------- </P> <P>global procedure setSubFields(atom parent,integer parts,sequence pData) <BR>integer len_,pointer<BR>atom mem_loc,struc_len,x <BR>sequence rect<BR>len_ = length(pData)<BR>if len_ != parts then<BR>wait_abort("length of pData should equal numer of parts")<BR>end if <BR>struc_len=parts*4 <BR>pointer = 1 <BR>mem_loc = get_mem(0,struc_len)<BR>for i = 0 to (struc_len-4) by 4 do<BR>x = pData[pointer]<BR>if x<1 and x>0 then<BR>rect = getRect(parent) <BR>x = floor(rect[3]*x) <BR>end if<BR>poke4(mem_loc+i,x) <BR>pointer += 1<BR>end for <BR>len_ = sendMessage(parent,SB_SETPARTS,parts,mem_loc)<BR>end procedure </P> <P>---------------------------------------------------------<BR>--Procedure: setStatusText(id,part,text)<BR>--Use :Use this function to set text to a status bar item<BR>-- :use 1 for part if you have a simple status bar<BR>--------------------------------------------------------- </P> <P>global procedure setStatusText(atom id,integer part,object text) <BR>atom ret,block<BR>if atom(text) then<BR>text = sprintf("%g",text)<BR>end if <BR>block = get_block()<BR>text = get_mem(block,text) <BR>if part >0 then part-=1 end if<BR>ret = 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 </P> <P>---------------------------------------------------------<BR>--Function: getStatusText(atom id,integer part)<BR>--Use :It retrieves text from a Status Bar. If the Status<BR>-- :bar is a simple one then simply use getWindowText(id)<BR>-- : or use this function but with part as 0<BR>--Return :Itreturns text from the specified part of a text bar<BR>--------------------------------------------------------- </P> <P>global function getStatusText(atom id,integer part)<BR>integer len_,mem_stack,buffer_loc,retval<BR>sequence str <BR>if part >0 then part-=1 end if<BR>len_ = sendMessage(id,SB_GETTEXTLENGTHA,part,0) <BR>len_ = LOWORD(len_) <BR>mem_stack = get_block()<BR>buffer_loc= get_mem(mem_stack,len_) <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> return str<BR>end function </P> <P>---------------------------------------------------------<BR>--Function: Custom_Status(parent)<BR>--Use :This is my custom made status window.<BR>--Return :It returns the handle of the new created Wnd<BR>--------------------------------------------------------- </P> <P>global function Custom_Status(atom parent) <BR>atom status_id,art <BR>status_id = CreateStatusBar(parent) <BR>setSubFields(status_id,4,{140,200,260,380}) </P> <P>--##### --Areas of Concern (The lparam of the SB_SETTEXTA message)<BR>--#### --According to help file,this parameter represents 32 bits of data <BR>--### --Qn. What do they mean 32bits of Data?, Do they mean the call_back()<BR>--## --From a separate procedure handling the Status Window?<BR>art = 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 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 = WM_CREATE then <BR>statuswnd = Custom_Status(hwnd)<BR>elsif iMsg = WM_SIZE then <BR>if c_func(zIsWindow,{statuswnd}) then<BR>status_retval = sendMessage(statuswnd,iMsg,wParam,lParam)<BR>setSubFields(statuswnd,5,{.5,.6,.7,.8,.9}) <BR>end if <BR>elsif iMsg = WM_DRAWITEM then<BR>c_proc(zUpdateWindow, {hwnd})<BR>childwnd_id= peek4u(lParam+4 ) <BR>part = peek4u(lParam+8 ) <BR>wnd_hwnd = peek4u(lParam+20) <BR>hdc = peek4u(lParam+24) <BR>rcItem = peek4u(lParam+28) <BR>bit = peek4u(lParam+32) </P> <P>bitdc = c_func(zCreateCompatibleDC,{hdc})<BR>bit = c_func(zSelectObject,{bitdc,img}) <BR>part = c_func(zBitBlt,{hdc,rcItem,3,32,32,bitdc,0,0,#CC0020})<BR>releaseDC(statuswnd,hdc) <BR>return 0</P> <P> </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--