LPCSTR?

BlitzPlus Forums/BlitzPlus Programming/LPCSTR?

Alaric(Posted 2007) [#1]
I am trying to use user32.dll to create windows gadgets that aren't included in blitz. However, some of the function mention a variable of type LPCSTR. Is this just a simple pointer to a null terminated char[] in C++? Is there any way to use these in blitz so that I can use these unlisted functions?


b32(Posted 2007) [#2]
It could be those parameters return something. Then you could try and create a bank and pass the handle to that. If returning something isn't needed, I think you could also enter a zero there, or pass a string.


Andy_A(Posted 2007) [#3]
Long Pointer C STRing


Alaric(Posted 2007) [#4]
O.k, so then can someone please help me with this code? It's just a practice run now, but I need to get it to work for my gui creation program.



The problems arise with the API_CreateWindow() userlib. Here's a link to the msdn createwindow() function definition http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/CreateWindow.asp
and here's my userlib decl for API_CreateWindow().

.lib "user32.dll"
API_CreateWindow% (lpClassName%,lpWindowName%,dwStyle%,x%,y%,width%,height%,hWndParent%,hMenu%,hInstance%,lpParam%) : "CreateWindow"

Can you tell me what's wrong with this code? You won't be able to run it because LpCstr() is from a dll and setwindowpos/setwindowlong are from userlibs as well.


Seldon(Posted 2007) [#5]
LPCSTR is a pointer to a null (zero) terminated sequence of bytes (a typical string in C) , so use banks.

Include "Includes\WIN32CONST.bb"

window=CreateWindow("MyWin",0,0,200,200,Desktop(),1)
SetWindowLong(QueryObject(window,1),GWL_STYLE,WS_VISIBLE+WS_CAPTION+WS_SYSMENU+WS_SIZEBOX+WS_MINIMIZEBOX+WS_MAXIMIZEBOX)
SetWindowPos(QueryObject(window,1),0,100,100,200,200,SWP_FRAMECHANGED)

LPCSTR_button=CreateBank(7) ; BUTTON+0
StringToBank(LPCSTR_button,"BUTTON")
LPCSTR_ok=CreateBank(3) ; OK+0
StringToBank(LPCSTR_ok,"OK")
API_CreateWindow(LPCSTR_button,LPCSTR_ok,WS_VISIBLE,10,10,100,100,QueryObject(window,1),0,0,0)

Function StringToBank(bank%, stringTMP$)
	Local stringSIZE%
	Local offset%=0
	stringSIZE=Len(stringTMP$)
	Repeat
		PokeByte(bank,offset,Asc(Mid$(stringTMP$,offset+1,1)))
		offset=offset+1
		stringSIZE=stringSIZE-1
	Until stringSIZE=0
	PokeByte(bank,offset,0)	; inserice uno zero finale, utile per passare stringhe
End Function



Alaric(Posted 2007) [#6]
Thanks, I found out that I accidentally added an extra ,0 to api_createwindow. Anyways, I think I fixed most of the creation, but how do I get the current hinstance? I saw another example that used getmodulehandle, but I can't get that to return anything except for 0.