1. machine exception

I get this error when calling Win32 API TextOut():

A machine-level exception occurred during execution of this statement (signal 5)  
    hDC = 1476465858 
    left = 10 
    top = 10 
    text = {116't',101'e',115's',116't'} 
    pUnicode = 36167784 
    result = <no value> 

global constant iGetDC=define_c_func(user32lib,"GetDC",{C_UINT},C_UINT) 
global function GetDC(atom hWnd) 
  return c_func(iGetDC,{hWnd}) 
end function 
 
global constant iReleaseDC=define_c_func(user32lib,"ReleaseDC",{C_UINT,C_UINT},C_UINT) 
global procedure ReleaseDC(atom hwnd,atom hDC) 
object fnVal 
  fnVal = c_func(iReleaseDC,{hwnd,hDC}) 
end procedure 
 
constant iTextOut=define_c_func(gdi32lib,"TextOutW",{C_UINT,C_INT,C_INT,C_POINTER,C_INT},C_UINT) 
/* 

  ref: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145133(v=vs.85).aspx 
  writes a character string at the specified location, using the currently selected font, 
  background color, and text color. 
  input: hDC, handle of display context 
         left, x coordinate  
         top,  y coordinate 
         text,  text to write 
*/ 
public procedure TextOut(atom hDC, integer left, integer top, sequence text) 
atom pUnicode, result 
     
    pUnicode = allocate_unicode(text)  
    result = c_func(iTextOut,{hDC, pUnicode,left,top,length(text)}) 
    free(pUnicode)  
end procedure -- TextOut 
 
-- main file code 
      atom hDC = GetDC(hWnd) 
      TextOut(hDC,10,10,"test") 
      ReleaseDC(hWnd,hDC) 
 

ajout: curieusement si j'utilise DrawText() au lieu de TextOut() je n'ai pas de problème...

Jacques

new topic     » topic index » view message » categorize

2. Re: machine exception

coconut said...

I get this error when calling Win32 API TextOut():

A machine-level exception occurred during execution of this statement (signal 5)  
    hDC = 1476465858 
    left = 10 
    top = 10 
    text = {116't',101'e',115's',116't'} 
    pUnicode = 36167784 
    result = <no value> 

public procedure TextOut(atom hDC, integer left, integer top, sequence text) 
atom pUnicode, result 
     
    pUnicode = allocate_unicode(text)  
    result = c_func(iTextOut,{hDC, pUnicode,left,top,length(text)}) 

should that be?:

    result = c_func(iTextOut,{hDC, left,top,pUnicode,length(text)})  
new topic     » goto parent     » topic index » view message » categorize

3. Re: machine exception

ne1uno said...
coconut said...

I get this error when calling Win32 API TextOut():

A machine-level exception occurred during execution of this statement (signal 5)  
    hDC = 1476465858 
    left = 10 
    top = 10 
    text = {116't',101'e',115's',116't'} 
    pUnicode = 36167784 
    result = <no value> 

public procedure TextOut(atom hDC, integer left, integer top, sequence text) 
atom pUnicode, result 
     
    pUnicode = allocate_unicode(text)  
    result = c_func(iTextOut,{hDC, pUnicode,left,top,length(text)}) 

should that be?:

    result = c_func(iTextOut,{hDC, left,top,pUnicode,length(text)})  

That's right! Sometimes I have the nose to close on it to see the obvious mistake. Thanks!

Jacques

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu