Page 1 of 1

[PB4.60 x86,Win7] SendMessage_ or structure is different

Posted: Thu Nov 10, 2011 10:00 pm
by peterb
Hi, I test code for sending messages to change directories in Total Commander and if I run this code in Purebasic 4.51 then everything works fine, but if I run this code in Purebasic 4.60 then nothing happens. Both versions of Purebasic show me same values in debug mode.

Can You please test it?

My configuration is: Windows 7 Professional 64bit - Czech version, Purebasic 4.51 x86 and Purebasic 4.60 x86

Thanks, Petr

Code: Select all


Global total_hwnd

Procedure EnumWindows ( hwnd, lParam )
  
  window_class.s = Space ( #MAX_PATH + 1 )
  
  GetClassName_( hwnd, @window_class, #MAX_PATH )
  
  If window_class = "TTOTAL_CMD"
    
    text.s = Space ( #MAX_PATH )
    text_length = #MAX_PATH
    
    GetWindowText_( hwnd, @text, text_length )
    
    Debug text
    total_hwnd = hwnd
    
    ProcedureReturn #False
    
  EndIf
  ProcedureReturn #True
  
EndProcedure

EnumWindows_ ( @EnumWindows(), 0 )

Debug total_hwnd

string2send.s = "c:\windows" + Chr ( 13 ) + "c:\windows\system32"

*stringdata.COPYDATASTRUCT = AllocateMemory ( SizeOf ( COPYDATASTRUCT ) )

With *stringdata
  
  \dwData = Asc("C") + 256 * Asc("D")
  \cbData = StringByteLength ( string2send ) + SizeOf ( CHARACTER )
  \lpData = @string2send
  
EndWith   

Debug *stringdata\dwData
Debug *stringdata\cbData
Debug string2send

Debug SendMessage_( total_hwnd, #WM_COPYDATA, #Null, *stringdata )


Re: [PB4.60 x86,Win7] SendMessage_ or structure is different

Posted: Fri Nov 11, 2011 12:40 am
by netmaestro
I'm using Windows 7 Home Premium 32bit and PB 4.60 x86. All seems to work fine, the directories change when I run the program.

Re: [PB4.60 x86,Win7] SendMessage_ or structure is different

Posted: Fri Nov 11, 2011 8:11 am
by Little John
peterb:
The code works fine here on Windows XP SP3 x86 with PB 4.60 final and Total Commander 7.56a ... but only if the compiler option

Code: Select all

[ ] Create unicode executable
is unchecked. Maybe it is accidentally checked for your current code?

Regards, Little John

Re: [PB4.60 x86,Win7] SendMessage_ or structure is different

Posted: Fri Nov 11, 2011 12:25 pm
by gnozal
Works fine here (ANSI mode).

In unicode mode, something like this should do the trick :

Code: Select all

CompilerIf #PB_Compiler_Unicode
  tmpstring2send.s = "c:\windows" + Chr (13) + "c:\windows\system32"
  string2send.s = Space(StringByteLength(tmpstring2send) + 3)
  PokeS(@string2send + 3, tmpstring2send,  #PB_Any, #PB_UTF8)
  ; UTF-8 BOM header
  PokeA(@string2send, $EF)
  PokeA(@string2send + 1, $BB)
  PokeA(@string2send + 2, $BF)
CompilerElse
  string2send.s = "c:\windows" + Chr ( 13 ) + "c:\windows\system32"
CompilerEndIf
PB 4.60 x86 final, Windows XP sp3 fr, TotalCMD 7.56a

Not a PB bug anyway...

Re: [PB4.60 x86,Win7] SendMessage_ or structure is different

Posted: Sat Nov 12, 2011 10:28 pm
by peterb
Thanks for checking. After restart it's working properly. Normally I use sleep mode, because I'm lazy to open all programs and source files every time when system starting.

Petr