Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Source Help

assignment error

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

assignment error

hi,

I got this error

[39,34]: Expected procedure/function call or number or hexadecimal or register or constant or procedure address but found hInstance in [Win.zir] Code: wndClass.hInstance = hInstance;

from this code

//handles
Dword hMainFRM;
procedure CreateWin()
{
  const  className = 'ZMainFRM';
  tagWndClassA wndClass;

  Dword hInstance = GetModuleHandle(nil);

  wndClass.hbrBackground = COLOR_BACKGROUND;
  wndClass.hInstance = hInstance;
  wndClass.lpszClassName = className;
  wndClass.lpfnWndProc = @WindowProc;	

  RegisterClass(@wndClass);
  hMainFRM = CreateWindowEx(0, className, 'window Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1024, 768, 0, 0, hInstance, nil);
  ShowWindow(hMainFRM, SW_SHOWNORMAL);
}

any help please?

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

this is a problem with local variables, you can try

eax = hInstance;
wndClass.hInstance = eax;
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

compiled okay now.

but found strange things here

when run the program no window creating at all , and when put inline term before the

CreateWin procedure it works fine?

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

seems still a bug with local variables, i'm taking a look into it now :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK seems i have a few bugs to fix, else here it is working:

procedure CreateWin()
{
	const className = 'ZMainFRM';
	tagWndClassA wndClass;
	Dword hInstance = GetModuleHandleA(nil);	

	m_strFill(@wndClass, 40, 0);

	wndClass.hbrBackground = COLOR_BACKGROUND;
	eax = hInstance;
	wndClass.hInstance = eax;
	eax = @className;
	wndClass.lpszClassName = eax; 
	
	mov eax, @WindowProc;
	wndClass.lpfnWndProc = eax;
		
	if (RegisterClassA(@wndClass) == 0) {
		eax = GetLastError();	
		print('RegisterClassA error: ',eax:int,'\r\n');
	}
	hMainFRM = CreateWindowExA(0, className, 'window Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1024, 768, 0, 0, hInstance, nil);
	
	if (hMainFRM == null) {
		eax = GetLastError();
		print('CreateWindowEx error: ',eax:int,'\r\n');
	}
	ShowWindow(hMainFRM, SW_SHOWNORMAL);
}
Colin admin
Posts
928
Threads
49
Location
Bulgaria

I've just updated the beta version which fixes these problems

procedure CreateWin() {
	const className = 'ZMainFRM';
	tagWndClassA wndClass;
	Dword hInstance = GetModuleHandleA(nil);	

	m_strFill(@wndClass, sizeof tagWndClassA, 0);

	wndClass.hbrBackground = COLOR_BACKGROUND;
	wndClass.hInstance = hInstance;
	wndClass.lpszClassName = className; 
	wndClass.lpfnWndProc = @WindowProc;
		
	if (RegisterClassA(@wndClass) == 0) {
		eax = GetLastError();	
		print('RegisterClassA error: ',eax:int,'\r\n');
	}
	hMainFRM = CreateWindowExA(0, className, 'window Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1024, 768, 0, 0, hInstance, nil);
	
	if (hMainFRM == null) {
		eax = GetLastError();
		print('CreateWindowExA error: ',eax:int,'\r\n');
	}
	ShowWindow(hMainFRM, SW_SHOWNORMAL);
}
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok works fine , thanks for debug the local variable error.

hope by 2013 ziron will be bug free.

BTW , why you did not declare functions name of kernel32 library without 'A' at the end.

some thing like this

function GetModuleHandle = GetModuleHandleA(Pointer lpModuleName): DWord; stdcall;

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

at some point i planned to add unicode support

$if defined(UNICODE):
  //etc

since alot of the features are added already, once the bugs are ironed out of all current features, it should then be bug-free :) only new features/opcodes would be potentially buggy...