Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Porting a Delphi Application
Porting a Delphi Application [message #11475] Sat, 15 September 2007 03:40 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Hi,

I have a Delphi application that I have been (very slowly) developing for quite some time now and for a while I have been thinking about porting the code to some C++ GUI library.

I don't like C++Builders proprietary extensions to C++, GTK is too C-ish (gobject) and can sometimes be very slow on Windows (the GUI), and Qt is one precompiled mess. I researched some other GUI toolkit's too, and I think U++ would be the best for me (even though it's too nonconformist).

So I will try to do the port, at first as a test, and if it works out I will continue add future developments to the U++ version. If it doesn't work, nobody will ever know Smile.

I've gotten quite a good idea of the U++ API, but I can't seem to find and equivalent to Windows MDI Application style windows (TopWindows inserted into TopWindows, with tiling, cascading, ... support). Is MDI supported by U++ or do I have to convert my application to a SDI interface?

Thank you
Re: Porting a Delphi Application [message #11480 is a reply to message #11475] Sat, 15 September 2007 13:44 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
So I started porting and managed to create the File menu with relative ease. It takes some time to get used to the package management scheme in TheIDE, it's image editor and the fact that it is it's own little world, which is surprisingly self-contained.

The layout editor is great, but is not well suited for creating really complex layouts and it seems to favour composing a large number of simple layouts to achieve this goal. And it has no frame support (which I think is a design choice) and no menu editor. But it still helps a lot and I'm glad to have it.

But even after this brief time of exposure to U++ I have identified some issues. I will describe them:

1. My applications exe doesn't have the correct icon (it uses the generic one) when I compile my application in Optimal mode. I compiled some of the example applications to, and these also lack the correct icon. But if I compile it in Debug mode, the icons are fine.

2. If the layout designer or image editor is in the main tab of the editor in the moment the application launches (F5), these editors loose their advanced functionality and revert back to a plain text editor.

3. Fullscreen windows (under Windows) get a border and a title bar if the window looses focus.

4. If I create a frame parameterised with a Button (FrameLeft<Button> for example), the Button will have a strange blue-ish skin. But if I create a Frame with a layout which contains a Button, the Button has a normal skin. Is this intentional?

5. How do you activate the MacOS theme under Windows as seen in the screenshot (this is not an issue, just a question).

I think I forgot another one, and if I stumble upon it I will post again.

Thank You.
Re: Porting a Delphi Application [message #11511 is a reply to message #11475] Sun, 16 September 2007 11:16 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I managed to solve the icon problem. Seems I need to have the icon exported into "icon.ico". I thought that those 6 bytes icons were strange...

But I found another bug. If a create a menu with a caption containing the accessor key multiple times (for example "Zoom &Out"), when I press Alt the first of that character will be highlighted (as if I had "Z&oom Out"). This is a minor detail but things like this shouldn't be ignored.

Thank You
Re: Porting a Delphi Application [message #11513 is a reply to message #11475] Sun, 16 September 2007 12:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 14 September 2007 21:40


(even though it's too nonconformist).



Yes, it is.

Quote:


I've gotten quite a good idea of the U++ API, but I can't seem to find and equivalent to Windows MDI Application style windows (TopWindows inserted into TopWindows, with tiling, cascading, ... support). Is MDI supported by U++ or do I have to convert my application to a SDI interface?



No, there is no MDI support.

Mirek
Re: Porting a Delphi Application [message #11514 is a reply to message #11480] Sun, 16 September 2007 12:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sat, 15 September 2007 07:44


1. My applications exe doesn't have the correct icon (it uses the generic one) when I compile my application in Optimal mode. I compiled some of the example applications to, and these also lack the correct icon. But if I compile it in Debug mode, the icons are fine.



Debug mode is trange, however to procedure is to activate .ico export and add .rc file that uses it. See ide/.rc file as an example (the icon is BTW usually the only use for .rc in U++).

Quote:


2. If the layout designer or image editor is in the main tab of the editor in the moment the application launches (F5), these editors loose their advanced functionality and revert back to a plain text editor.



That is feature, not error Smile The problem is that these files are, through some macro hackery, in fact valid C++ sources that can be stepped through by debugger.

Press Ctrl+T to get designer back.

Quote:


3. Fullscreen windows (under Windows) get a border and a title bar if the window looses focus.



Well, fullscreen windows are not quite typical, this might be a bug. Cared to post a testcase? (BTW, next time please post problems to more appropriate forums, this is really mostly about interesting apps being developed in U++, not problem solving area... your problem might be unnoticed here).

Quote:


4. If I create a frame parameterised with a Button (FrameLeft<Button> for example), the Button will have a strange blue-ish skin. But if I create a Frame with a layout which contains a Button, the Button has a normal skin. Is this intentional?



Yes, tries to immitate the appearance of ComboBox buttons.

Quote:


5. How do you activate the MacOS theme under Windows as seen in the screenshot (this is not an issue, just a question).



Google: "uxtheme".

Mirek
Re: Porting a Delphi Application [message #11516 is a reply to message #11511] Sun, 16 September 2007 12:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 16 September 2007 05:16


But I found another bug. If a create a menu with a caption containing the accessor key multiple times (for example "Zoom &Out"), when I press Alt the first of that character will be highlighted (as if I had "Z&oom Out"). This is a minor detail but things like this shouldn't be ignored.



Actually, nobody cares about explicitly defining '&' keys - let U++ runtime generate them for you... and perhaps do it manually in cases when you do not like automatic assignment. You can also assign only some and let U++ do the rest.

Mirek

[Updated on: Sun, 16 September 2007 12:33]

Report message to a moderator

Re: Porting a Delphi Application [message #11523 is a reply to message #11475] Sun, 16 September 2007 15:49 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Quote:


Actually, nobody cares about explicitly defining '&' keys - let U++ runtime generate them for you... and perhaps do it manually in cases when you do not like automatic assignment. You can also assign only some and let U++ do the rest.


And it seems it does quite a good job assigning the keys. But is still wish it would respect my explicitly assigned position, because a have "Zoom &In" and "Zoom &Out" and I would like to keep the "_"s aligned. But this little detail won't make me think less of U++, and I must admit that I'm impressed.

Quote:


No, there is no MDI support.


Well with owner draw widgets maybe I could emulate somehow MDI behaviour. Or at least I need a Window menu which allows you to switch between all your open documents.

Quote:


BTW, next time please post problems to more appropriate forums, this is really mostly about interesting apps being developed in U++, not problem solving area... your problem might be unnoticed here.


Sorry, I wanted to keep all info regarding this project in one place.

But to keep with the theme of this thread, I will need some custom components. Most of them are highly specialized and I don't see a general use for them, but one could be useful. It is a foldable panel. It looks like a LabelBox with a Button instead of the label, and by clicking it you can open and close it. In my original application this is done by a Panel, a Bevel, a Button and hand-coded folder behaviour. This is not that nice, and I'm going to try to develop a custom component which at least should extend to a property specified size (even better would be if I can make it to auto-detect the correct size and hide, show and align it's children. I attached a picture with this component.
Re: Porting a Delphi Application [message #11525 is a reply to message #11523] Sun, 16 September 2007 15:51 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Forgot to attach...
  • Attachment: panel.PNG
    (Size: 2.64KB, Downloaded 502 times)
Re: Porting a Delphi Application [message #11531 is a reply to message #11523] Sun, 16 September 2007 20:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 16 September 2007 09:49

Quote:


Actually, nobody cares about explicitly defining '&' keys - let U++ runtime generate them for you... and perhaps do it manually in cases when you do not like automatic assignment. You can also assign only some and let U++ do the rest.


And it seems it does quite a good job assigning the keys. But is still wish it would respect my explicitly assigned position, because a have "Zoom &In" and "Zoom &Out" and I would like to keep the "_"s aligned. But this little detail won't make me think less of U++, and I must admit that I'm impressed.



You can, just do not expect U++ to check your assignments (yet? Smile

Quote:


Or at least I need a Window menu which allows you to switch between all your open documents.



See examples/UWord

Mirek
Re: Porting a Delphi Application [message #11536 is a reply to message #11475] Sun, 16 September 2007 23:06 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Mirek: did you understand his problem with Zoom Out?
It looks to me like you didn't. He doesn't need U++ to check his assignments, he just needs that the underlined "o" will be the one in "Out" word, not the first one in "Zoom", because he didn't specify it there in Zoom, but in Out.
Re: Porting a Delphi Application [message #11539 is a reply to message #11536] Sun, 16 September 2007 23:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I see thanks. (ops)
Re: Porting a Delphi Application [message #11542 is a reply to message #11539] Mon, 17 September 2007 05:48 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Quote:

See examples/UWord

Thanks, that served as a quick fix. I don't like the multiple windows but this way I don't have to wory about multiple documents in the same instance of the main window.

Quote:

I see thanks. (ops)

If you don't have time, maybe I could find some time in weekend to look over the code, maybe find a way to fix this.

Regarding that drop down panel control, I managed to create one. It works well enough for the time being, even though the code is rough, functionality is missing and it has problems with auto sizing. But it gets me going, so it’s a good thing. I can imagine a custom Bar component which would accept such controls as children and automatically align them vertically one under the other as their size change.

I attached the control's source. I don't have any experience in writing U++ controls, so maybe I get some feedback. And I couldn't find a centralized place where position or size change is handled (except WndSetPos, but that is OS dependent).
  • Attachment: DropPane.zip
    (Size: 1.09KB, Downloaded 436 times)
Re: Porting a Delphi Application [message #11544 is a reply to message #11542] Mon, 17 September 2007 09:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 16 September 2007 23:48


I attached the control's source. I don't have any experience in writing U++ controls, so maybe I get some feedback. And I couldn't find a centralized place where position or size change is handled (except WndSetPos, but that is OS dependent).



Ctrl::Layout

Mirek
Re: Porting a Delphi Application [message #11545 is a reply to message #11542] Mon, 17 September 2007 10:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 16 September 2007 23:48


I attached the control's source.



Usual custom here, when you post some sources like this, is to use package and perhaps provide another one as demonstration - that way downloaders can just unpack to some package nest, start theide, choose the test and run it.

This is not a complaint, just a note - I guess it is time to write U++ netiquette summmary Smile

Mirek
Re: Porting a Delphi Application [message #11564 is a reply to message #11545] Mon, 17 September 2007 19:40 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Mon, 17 September 2007 10:03


Usual custom here, when you post some sources like this, is to use package and perhaps provide another one as demonstration - that way downloaders can just unpack to some package nest, start theide, choose the test and run it.

This is not a complaint, just a note - I guess it is time to write U++ netiquette summmary Smile



I will post another improved version (current one gives error when trying to use it as base for a template layout because it misses a SetRect function with a Rect parameter) once it is ready and I'll try to have a proper package format. Previous post was only so people get an idea of what I'm trying to do (and if can be done easier point me in the right direction).

But I have a functional (barely) DropPane and now I'm trying to insert inside an array of 2x4 ToolButtons (I'm not using button because I need them to be flat-looking), like in the attached picture.
index.php?t=getfile&id=719&private=0
Layout and positioning is very important, so I did not use a ToolBar component, instead I hand placed all the buttons. I also need them to check when the user click on them. I managed to do this, but unfortunately I had to use pointers (old habits die hard). I wonder if there is a better way to do this in a U++ style?

layout
LAYOUT(ToolsLayout, 60, 200)
	ITEM(ToolButton, btnMove, LeftPosZ(8, 22).TopPosZ(24, 22))
	ITEM(ToolButton, btnEdit, LeftPosZ(30, 22).TopPosZ(24, 22))
	ITEM(ToolButton, btnLine, LeftPosZ(8, 22).TopPosZ(46, 22))
	ITEM(ToolButton, btnBezier, LeftPosZ(30, 22).TopPosZ(46, 22))
	ITEM(ToolButton, btnRectangle, LeftPosZ(8, 22).TopPosZ(68, 22))
	ITEM(ToolButton, btnEllipse, LeftPosZ(30, 22).TopPosZ(68, 22))
END_LAYOUT


code
struct ToolsDropPane: public WithToolsLayout<DropPane> {
	
	typedef ToolsDropPane CLASSNAME;
	
	ToolsDropPane();	
	
	void SetActive(ToolButton *btn);
};

ToolsDropPane::ToolsDropPane()	
{
	CtrlLayout(*this);
	
	btnMove.Image(CBPImages::Move()).Text("Modify");
	btnMove.WhenAction = THISBACK1(SetActive, &btnMove);
	btnEdit.Image(CBPImages::Edit()).Text("Edit");
	btnEdit.WhenAction = THISBACK1(SetActive, &btnEdit);
	btnLine.Image(CBPImages::Line());
	btnLine.WhenAction = THISBACK1(SetActive, &btnLine);
	btnBezier.Image(CBPImages::Bezier());
	btnBezier.WhenAction = THISBACK1(SetActive, &btnBezier);
	btnRectangle.Image(CBPImages::Rectangle()).Text("Rectangle");
	btnRectangle.WhenAction = THISBACK1(SetActive, &btnRectangle);
	btnEllipse.Image(CBPImages::Ellipse()).Text("Ellipse");
	btnEllipse.WhenAction = THISBACK1(SetActive, &btnEllipse);
	
	//btnLine.Check(true);
}

void ToolsDropPane::SetActive(ToolButton *btn)
{
	btn->Check(true);
}


On the other hand, you will notice that the third and fourth button doesn't have a Text. This is intentional. When I don't specify a text to a button inserted like this into a layout, I get a weird tool tip for it: "(Alt+Shift+address)". Does this mean anything?
  • Attachment: panel2.PNG
    (Size: 1.88KB, Downloaded 1512 times)
Re: Porting a Delphi Application [message #11570 is a reply to message #11564] Mon, 17 September 2007 22:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oh, no, if you want to follow U++ approach, there is nothing wrong with pointing to things.

What we try to avoid is to use pointers to manage resources.

Your use of pointer here is definitely OK and optimal solution.

BTW, before you will reach that point, drawing primitices in U++ are intentionally very dumb. There is no bezier Smile

Mirek
Re: Porting a Delphi Application [message #11597 is a reply to message #11480] Tue, 18 September 2007 20:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sat, 15 September 2007 07:44


3. Fullscreen windows (under Windows) get a border and a title bar if the window looses focus.



This is found to be a bug; now fixed.

Quick fix:

void TopWindow::SyncCaption()
{
	LLOG("SyncCaption");
	if(fullscreen)     // ADD
		return;    // THIS :)
	HWND hwnd = GetHWND();
	if(hwnd) {
		style = ::GetWindowLong(hwnd, GWL_STYLE);
		exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
	}


Mirek
Re: Porting a Delphi Application [message #11600 is a reply to message #11597] Tue, 18 September 2007 21:16 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Tue, 18 September 2007 20:57


This is found to be a bug; now fixed.



Thanks. It worked. Glad I could help at least in this minor way. What do you think about the strange tooltips I mentioned in my last post?

By the way, how does bug-fixing work? I fixed it in my source-tree, but will others have to wait for next release or are the bugs fixed retroactivelly?
Re: Porting a Delphi Application [message #11610 is a reply to message #11600] Wed, 19 September 2007 11:07 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
On the other hand ToolButton doesn't refresh if I call Check(false) after it has been set to true if it is not inserted into a ToolBar. I get the distinct feeling that ToolButton was no intended to be used on it's own. And AFAIK there is no GetCheck or other method to verify if it is checked or not. ButtonOption has such capabilities.
Re: Porting a Delphi Application [message #11615 is a reply to message #11600] Wed, 19 September 2007 12:18 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Tue, 18 September 2007 15:16

luzr wrote on Tue, 18 September 2007 20:57


This is found to be a bug; now fixed.



Thanks. It worked. Glad I could help at least in this minor way. What do you think about the strange tooltips I mentioned in my last post?



Sorry missed it.

ToolButtons show its accelerator in the tip by default. I think this is related.

Quote:


By the way, how does bug-fixing work? I fixed it in my source-tree, but will others have to wait for next release or are the bugs fixed retroactivelly?



It will be in next dev release. At that point, you are supposed to simply replace the whole uppsrc with the new one...

Mirek
Previous Topic: How to write a dll using Ultimate++?
Next Topic: embedded configuration data/values in self for a executable
Goto Forum:
  


Current Time: Thu Apr 18 15:10:00 CEST 2024

Total time taken to generate the page: 0.02499 seconds