Search found 21 matches

by thearr
Tue Jun 09, 2009 1:14 pm
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

1. BSTR that is used in VB is always a Unicode string (each symbol is coded with 2 bytes). It also has 2 bytes of zeros at the end of the string for compatibility with WinAPI functions, that usually use null-terminated strings (PB uses them as well).

2. I have tested one of a element of the array ...
by thearr
Sun Jun 07, 2009 7:31 pm
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

A kind programmer of VBForum give to me this solution in VB only.

This won't help you. Your problem is you'd like to pass a Unicode string from VB (BSTR) to DLL, compiled in ANSI mode. So all you have to do is to convert Unicode to ANSI no matter where:
in VB:
PostPosted: Thu Jun 04, 2009 12:03 ...
by thearr
Sat Jun 06, 2009 7:56 am
Forum: Coding Questions
Topic: How do I put a Shifted Return in a Stringgadget
Replies: 3
Views: 1605

With WM_CHAR lParam
Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table (MSDN).
by thearr
Fri Jun 05, 2009 11:52 am
Forum: Coding Questions
Topic: How do I put a Shifted Return in a Stringgadget
Replies: 3
Views: 1605

Hope it could be usefull as a starting point:

Global *WndProc

Procedure StringGadgetCallback(hwnd, uMsg, wParam, lParam)
If uMsg = #WM_CHAR
If wParam <> #CR And wParam <> #VK_BACK
If (Len(GetGadgetText(0))+1) % 14 = 13
SendMessage_(hwnd, uMsg, #CR, lParam)
EndIf
EndIf
EndIf ...
by thearr
Fri Jun 05, 2009 5:19 am
Forum: Coding Questions
Topic: 'SizeOf' array in PureBasic?
Replies: 21
Views: 3674

My way:

Code: Select all

Procedure SizeOfArray(*Array)
  ProcedureReturn PeekL(*Array-8)*PeekL(*Array-20)
EndProcedure

Dim MyArray.l(10,10)
Debug SizeOfArray(MyArray())
Debug 11*11*4
by thearr
Wed Jun 03, 2009 11:03 pm
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

:?:

Code: Select all

 MyArrayVB(0) = StrConv("one", vbFromUnicode)
 MyArrayVB(1) = StrConv("two", vbFromUnicode) 
by thearr
Wed Jun 03, 2009 10:41 pm
Forum: Coding Questions
Topic: Bold in MessageRequester (messagebox_()) ?
Replies: 2
Views: 932

A bit shorter but less safer :wink:

Procedure SetBoldMsgBox(*Title)
Repeat
hwnd = FindWindowEx_(FindWindow_(0, *Title), 0, @"Static", 0)
Until hwnd<>0
SendMessage_(hwnd, #WM_SETFONT, LoadFont(0, "Microsoft Sans Serif", 8, #PB_Font_Bold), 1)
EndProcedure

Title.s = "Bold Text example"
Text.s ...
by thearr
Wed Jun 03, 2009 8:11 pm
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

The passing of array works fine now, thanks to THEARR, but when i pass a string variable at my DLL i have square character in the messagerequester :shock:

ProcedureDLL MyFunctionPB(String.s, *ArrayFromVB)
MessageRequester("", String)
Dim MyArray.l(1)
CopyMemory(*ArrayFromVB, @MyArray(), 2*4 ...
by thearr
Fri May 29, 2009 3:27 pm
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

If you have the same code, who don't crash the RAD....i'm interesting :D
Because i prefer close the VB with the button "quit" :lol:

I haven't got the code, because I haven't got VB and can't test the code I post.

So, the next step: I think that the possible problem why VB crashes is that DLL ...
by thearr
Fri May 29, 2009 11:36 am
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

Kwaï chang caïne wrote:And i obtain a msgbox with a "o" in the titlebar and a "t" in the prompt :shock:
When i click ok......VB crash

KCC is very very sad :cry:
OK, we've almost got it.

Now try to chek "Unicode executable" option in PB IDE before compiling DLL.
by thearr
Fri May 29, 2009 10:14 am
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

Try this:

Code: Select all

***VB***
Private Declare Sub MyFunctionPB Lib "c:\MyDll.dll" (ByRef MyArray As Long)
***PB***
Dim MyArrayPB(1) as Long
And also declare MyArrayVB and MyArrayPB as global arrays.
by thearr
Fri May 29, 2009 9:55 am
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

I have try your method but i have an error "TypeArgument BYREF incompatible" in VB
I have try to change the BYREF in the declaration by a BYVAL but i have another error "out of capacity" :cry:

VB Code

Private Declare Function MyFunctionPB Lib "c:\MyDll.dll" (ByVal MyArray As Byte) As Long ...
by thearr
Thu May 28, 2009 6:39 pm
Forum: Coding Questions
Topic: Passing VB Arrays
Replies: 42
Views: 12556

Re: Passing VB Arrays

Can I pass a VB string array into PureBasic?

I want to create a PureBasic DLL that handles arrays created in VB. e.g.

In VB:
Redim MyArray(2) as string
MyArray(0)="one"
MyArray(1)="two"
MyArray(2)="three"

PureBasicFunction MyArray()

Any help would be appreciated, thanks

I'm not sure if it ...
by thearr
Mon May 18, 2009 9:17 am
Forum: Coding Questions
Topic: Passing array of DLL Pure to VB [Resolved]
Replies: 16
Views: 4450

Hi, KCC.

I think that there is no way to know the array size except to pass it from DLL.

For example, like you did, as the firs element of the array:
ProcedureDLL TabloDansLaDll()
Static Dim Tablo.s(10)
Tablo(0) = Str(ArraySize(Tablo()))
Tablo(1) = "String 1"
;...
Tablo(9) = "String 9 ...
by thearr
Thu May 14, 2009 9:55 pm
Forum: Coding Questions
Topic: Passing array of DLL Pure to VB [Resolved]
Replies: 16
Views: 4450

Maybe this can help?

PB
ProcedureDLL LeTablo()
Static Dim Tablo.l(4)
Tablo(0) = @"Pure"
Tablo(1) = @"is "
Tablo(2) = @"your"
Tablo(3) = @"friend"
ProcedureReturn @Tablo(0)
EndProcedure

VB
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest as Any, source as Any, ByVal size ...