CreateWindowExW (is it possible?)

Just starting out? Need help? Post your questions and find answers here.
rogal79
User
User
Posts: 11
Joined: Tue Feb 10, 2004 3:08 pm
Location: Poland, Toruñ

CreateWindowExW (is it possible?)

Post by rogal79 »

Can somebody help me how to display window by "CreateWindowExW"
from User32.dll
I'm trying it but I can display winodw only by "CreateWindowExA"


My code:

Code: Select all

hWnd.l = CallFunction(6, "CreateWindowExW", #WS_EX_TOOLWINDOW, "WC", "WT", #WS_VISIBLE | #WS_OVERLAPPEDWINDOW | #WS_SIZEBOX , x, y, w, h, 0, 0, GetModuleHandle_(#NULL), 0)
but it works ok:

Code: Select all

 hWnd.l = CallFunction(6, "CreateWindowExA", #WS_EX_TOOLWINDOW, "WC", "WT", #WS_VISIBLE | #WS_OVERLAPPEDWINDOW | #WS_SIZEBOX , x, y, w, h, 0, 0, GetModuleHandle_(#NULL), 0)
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Class and text need to be in unicode (WideCharToMultiByte)
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

why not just use CreateWindowEx_()?
All these procedures should be already defined for you....
deadmoap
User
User
Posts: 79
Joined: Sun Feb 22, 2004 11:45 pm
Location: Riverdale, Utah
Contact:

Post by deadmoap »

"why not just use CreateWindowEx_()?
All these procedures should be already defined for you..."

For one thing, I believe that is CreateWindowExA, and he wants CreateWindowExW. Second, maybe he just has the demo, which doesn't have those predefined.
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

I modified this from some code on the forums to see if it was possible... And it works for me...

Code: Select all

Procedure.l WideStr(String$) 
  widelen.w = 2*Len(PeekS(String$))+2 
  widebuf.l = AllocateMemory(widelen) 
  longlen.w = MultiByteToWideChar_(#CP_ACP,0,String$,-1,widebuf,widelen) 
  ProcedureReturn widebuf 
EndProcedure 

hinst=GetModuleHandle_(0) 
classname$="mywndclass" 

Procedure mainwndproc(hwnd,msg,wparam,lparam) 
  Select msg 
    Case #WM_CREATE 
      ProcedureReturn 0 
      
    Case #WM_PAINT 
      ProcedureReturn 0 
      
    Case #WM_SIZE 
      ProcedureReturn 0 
      
    Case #WM_DESTROY 
      PostQuitMessage_(0) 
      ProcedureReturn 0 
      
    Default 
      ProcedureReturn DefWindowProc_(hwnd,msg,wparam,lparam) 
  EndSelect 
EndProcedure 

swc.WNDCLASSEX\cbSize=SizeOf(WNDCLASSEX) 
swc\style=#CS_HREDRAW|#CS_VREDRAW 
swc\lpfnWndProc=@mainwndproc() 
swc\cbClsExtra=0 
swc\cbWndExtra=0 
swc\hInstance=hinst 
swc\hIcon=0 
swc\hCursor=LoadCursor_(#Null,#IDC_ARROW) 
swc\hbrBackground=GetSysColorBrush_(#COLOR_MENU) ;#COLOR_WINDOW  ; #COLOR_MENU 
swc\lpszMenuName=#Null 
swc\lpszClassName=@classname$ 
swc\hIconSm=0 

RegisterClassEx_(@swc) 

*WideClassname=WideStr(classname$)
*WideTitle=WideStr("title")
OpenLibrary(0,"USER32.dll") 
hwmain=CallFunction(0,"CreateWindowExW",0,*WideClassname,*WideTitle,#WS_OVERLAPPEDWINDOW,100,100,600,400,0,#Null,hinst,0) 
CloseLibrary(0) 
FreeMemory(*WideClassname)
FreeMemory(*WideTitle)
Debug hwmain 
ShowWindow_(hwmain,#SW_SHOWNORMAL) 
UpdateWindow_(hwmain) 

;message loop 
While GetMessage_(@smsg.MSG,0,0,0) 
  TranslateMessage_(@smsg) 
  DispatchMessage_(@smsg) 
Wend 

DestroyWindow_(hwmain) 
End 
Post Reply