It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am trying to use docking as an alternative to embedding (related question) a TForm into a TWinControl (in this case a TTabSheet).
The user shouldn't notice that there are two different forms at all.
How do I avoid the close button and "drag bar" at the top of the docked form?
A simplified version of my code:
var
TabSheet: TTabSheet;
Form: TSubForm;
begin
TabSheet := TTabSheet.Create(Self);
TabSheet.DockSite := True;
TabSheet.PageControl := MainPageControl;
Form := TSubForm.Create(TabSheet);
Form.ManualDock(TabSheet);
Form.Show;
end;
PS: I don't want to use a TFrame which would of course be another alternative.
Update:
In this specific situation I am now considering to use TTabControl instead of TPageControl, so I can put all the controls into the master form.
I am using MVC/MVA anyway so the logic is separated from the UI.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I need to detect whether a specific window is minimized or not. For this purpose I have found two functions:
1.
function PAIsWindowMinimized(h: HWND): Boolean;
// Detects whether a window is minimized or not
var
wp: Winapi.Windows.WINDOWPLACEMENT;
begin
wp.length := SizeOf(Winapi.Windows.WINDOWPLACEMENT);
Winapi.Windows.GetWindowPlacement(h, #wp);
Result := wp.showCmd = Winapi.Windows.SW_SHOWMINIMIZED;
end;
2.
// Alternative (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-isiconic):
Winapi.Windows.IsIconic(h);
Which of the two alternatives is preferable? Or are they equally good in all situations?
IsIconic() is the proper and documented way to check if a window is minimized:
IsIconic function
Determines whether the specified window is minimized (iconic).
Window Features
The IsZoomed and IsIconic functions determine whether a given window is maximized or minimized, respectively. The GetWindowPlacement function retrieves the minimized, maximized, and restored positions for the window, and also determines the window's show state.
Using anything else is a hack at best. The fact that IsIconic() and GetWindowPlacement() internally check the HWND for the WS_MINIMIZE window style is just an implementation detail. The overhead of using these functions rather than checking the window style manually is negligible.
Stick with IsIconic(), it is the API that Microsoft specifically provides for this exact purpose.
The 'best' alternative is calling
(GetWindowLong(hwnd, GWL_STYLE) & WS_MINIMIZE).
I checked IsIconic and GetWindowPlacement functions in dissassembler and both internally compares windows styles with WS_MINIMIZE flag to determine if window is minimized.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have made an Arraylist of assistants (String name, int salary)
i would like to create a method that will print out all of the assistants, no matter how many we add to the list.
i want to be able to call the method from my run file when time is due.
how would i gå about making that method ?
thanks in advance
Assuming ArrayList definition to be: ArrayList asstList
private void PrintAssistnatList() {
for(Assistant asst:asstList) {
System.out.println("Name: "+asst.name+" salary: "+salary);
}
}
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want users to create their own list of controls such as TEdit, TCheckBox, TLabel, and other things. But how can I make another, when I have to predefine every control, but I don't know how many objects to define?
This is what you should do to create each object knowing its class type:
var
Obj:TControl;
begin
Obj := TEdit.Create(AOwner);
with Obj do begin
//Set properties here...
...
Parent := Self; //Assuming that you're writing code in your form class. if not, use object variable pointing to your form instead of `self`
end;
end;
To store unknown number of objects, you can either use a dynamic array, or link list, or you can even use the Controls property of the form.
This is the start of what you want to do (basics). You have plenty choices for implementing this part of your application. For example, you can have an array of TControl in your form class, and using Length and SetLength functions you can figure out how many objects your user has added to the form.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm creating a request queue in a custom thread TMyThread and I'm having difficulties defining a procedure type which can be used for a subroutine. I have a record which represents the request, a corresponding record pointer, and a procedure type which is used in the record and uses the record pointer...
type
PRequest = ^TRequest;
TResponseProc = procedure(Sender: TMyThread; Request: PRequest);
TRequest = record
Request: String;
Proc: TResponseProc;
Response: String;
end;
The problem is, when I implement a subroutine named ResponseProc and try to assign ResponseProc to a TResponseProc, it doesn't work, and the IDE returns this error message:
[DCC Error] MyProject.dpr(42): E2094 Local procedure/function 'ResponseProc' assigned to procedure variable
How do I define this procedure type TResponse and use it with a subroutine?
The record and procedure declarations are fine. The error message indicates that you're using a local procedure, which is one that's defined inside the scope of another function. You cannot use pointers to such functions because they require extra work to call, which cannot be expressed in an ordinary function pointer. (The compiler disallows creating pointers to functions that a caller won't know how to use.)
The solution is to move your function outside whatever other function you defined it in. If that's hard to do because the inner function uses variables from the outer function, then you'll have to figure out some other way of getting their values to the other function, such as by passing them as parameters, perhaps making them additional members of that request record.
Another option is to use a procedure reference, and then define the local procedure as an anonymous procedure instead. It can access local variables, although only Delphi and C++ Builder will know how to invoke it, so it's not an option if you need external API compatibility.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have been looking at system.pas
Delphi can call up to 65,000 memory blocks from windows
When Delphi makes an object dose it call a memory block for its data
And if so does the class some how load a register with a memory address for that memory block and an address for the methods too that is placed in another register.
Does any one know anything about this?
J Lex Dean.
With GetMem you call from windows a memory block that windows allocates up to 65,000 per process inside the 4 gig space. Depending on the fag depends on if the block is moved when resized with the data relocated in the resize or fixed and other issues.
Read about Windows or go to windows.pas and search on memory and call on your Delphi help
Thier is a lot of funny things with system.pas like1/ _ObjectProcess as if to add confustion to delphi programmers. Why do they not just put code in TObject. 2/ And how does code measure deliration size of an object.
Have a look at this excellent explanation about what's going on when Delphi creates new Class instances: The Rise and Fall of TObject from Hallvard Vassbotn
Although the original article appeared in 1998, most of it is still true for newer Delphi versions.
Here is the original article from The Delphi Magazine:The Delphi Magazine, July 1998
Where does your "65000 memory blocks" statistic comes from?
When a class instance is Created, the following class method is called before executing the Create method of the class (from _ClassCreate global function, which ensures that the instance is created only once, for all Create nested calls):
class function TObject.NewInstance: TObject;
Which calls GetMem to get memory from the heap, and then the following method:
class function TObject.InitInstance(Instance: Pointer): TObject;
This InitInstance method will:
Call FillChar() to put all the previously allocated memory to 0;
Initialize the Interface Table of the object.
The methods (i.e. not the interfaces) are defined in the class type itself, not during class instance creation.
There is no "register" containing what you say.
You have access to the object memory address by its self variable, or by trans-typing its variable to a pointer:
var O: TObject;
begin
O := TObject.Create;
writeln('O memory address is ',pointer(O));
O.Free;
end;
And before Delphi 2010 and its enhanced RTTI, you don't have access to all methods and fields of an object. Only published properties and methods are accessible to your code. But you must use RTTI. See TypInfo.pas unit.