Forum > Windows

[SOLVED] uses Windows gives errors

(1/1)

petevick:
I've added Windows to my uses section as I want to read the registry, but when I compile I get two errors at this line....


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  bmp := TBitmap.Create;
...the errors are....


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit1.pas(1379,18) Error: identifier idents no member "Create"unit1.pas(1379,18) Fatal: Syntax error, ";" expected but "identifier CREATE" found
...the uses section for Windows is as follows...


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$IFDEF WINDOWS}uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,  ComCtrls, Buttons, fileutil, Menus, BCButtonFocus, BCButton, BCTrackbarUpdown,  BCComboBox, BCLabel, LCLIntf, GraphUtil, LazFileUtils,  Contnrs, LCLType, BCTypes, process, jwatlhelp32, WinDirs, Windows;{$ENDIF} 
....if I remove the Windows uses there are no errors. I've had no problems with this particular section of the code until I added Windows uses.

I'm totally stumped by it, and I guess using the Windows uses is the only way to read registry keys.  :-\

TRon:

--- Quote from: petevick on January 23, 2024, 10:43:24 am ---....if I remove the Windows uses there are no errors. I've had no problems with this particular section of the code until I added Windows uses.

--- End quote ---
Windows unit has it's own declaration for f.e. TBitmap. Prefix either your use of TBitmap with graphics (e.g. graphics.TBitmap) or in case you wish to use a windows specific declaration of TBitmap with windows.TBitmap.


--- Quote ---I'm totally stumped by it, and I guess using the Windows uses is the only way to read registry keys.  :-\

--- End quote ---
The last included unit's declarations take precedence over declaration made in earlier included units.

Alternatively you can move your windows uses clause to before that of the graphics unit (which variable of type TBitmap you have to prefix then depends on the order of included units).


PS: Note that you do not have to use the windows unit yourself in case you wish to access the registry. There are abstractions for that such as fcl-registry.

petevick:

--- Quote from: TRon on January 23, 2024, 11:02:31 am ---.......
PS: Note that you do not have to use the windows unit yourself in case you wish to access the registry. There are abstractions for that such as fcl-registry.

--- End quote ---
That's the answer. Thanks for your help TRon  ;)

Navigation

[0] Message Index

Go to full version