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 » Community » Newbie corner » Creating a form inside a DLL
Creating a form inside a DLL [message #33825] Fri, 16 September 2011 20:04 Go to next message
tcler is currently offline  tcler
Messages: 4
Registered: September 2011
Junior Member
i write plugin for Download Master and have one question: how can i correctly initialize a form without a WinMain? my code:
StatDialog.h:
#include <CtrlLib/CtrlLib.h>
#include "StatPlugin.h"

using namespace Upp;

#define LAYOUTFILE "StatPlugin.lay"
#include <CtrlCore/lay.h>

class CStatDialog : public WithStatDialog<TopWindow> {
public:
	void setLnk (CStats &ptr);
	void Cal_CallBack ();
	void CBtn_CallBack();
	CStatDialog ();
	typedef CStatDialog CLASSNAME;
private:
	CStats _statslnk;
};

the form is created and then deleted when it calls (in other class):
UPP::Ctrl::InitWin32(0);
UPP::AppInitEnvironment__();
CStatDialog dform = CStatDialog();
dform.setPtr(stats_obj);
dform.RunAppModal();
UPP::DeleteUsrLog();
UPP::AppExit__();

it works but when app closes (dll detach) i get message "heap leaks detected" (debug build).
Re: Creating a form inside a DLL [message #33905 is a reply to message #33825] Sat, 24 September 2011 21:01 Go to previous messageGo to next message
tcler is currently offline  tcler
Messages: 4
Registered: September 2011
Junior Member
ok, next question. how to create custom sorting function for column in arrayctrl?
int cmpv(const Value& row1, const Value& row2)
{
	if (pureValue (String(row1)) > pureValue (String(row2))) return 0; else return 1;
}

function works fine, but sorting the table does not:
ExampleTable.ColumnAt(2).Sorting(cmpv);

access violation in Upp::sAC_ColumnSort::operator()(const Upp::Value & a, const Upp::Value & b):
ExampleTable.ColumnAt(2).Sorting(FnValueOrder(cmpv));

any ideas, please.
Re: Creating a form inside a DLL [message #33906 is a reply to message #33825] Sat, 24 September 2011 21:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
tcler wrote on Fri, 16 September 2011 14:04

i write plugin for Download Master and have one question: how can i correctly initialize a form without a WinMain? my code:
StatDialog.h:
#include <CtrlLib/CtrlLib.h>
#include "StatPlugin.h"

using namespace Upp;

#define LAYOUTFILE "StatPlugin.lay"
#include <CtrlCore/lay.h>

class CStatDialog : public WithStatDialog<TopWindow> {
public:
	void setLnk (CStats &ptr);
	void Cal_CallBack ();
	void CBtn_CallBack();
	CStatDialog ();
	typedef CStatDialog CLASSNAME;
private:
	CStats _statslnk;
};

the form is created and then deleted when it calls (in other class):
UPP::Ctrl::InitWin32(0);
UPP::AppInitEnvironment__();
CStatDialog dform = CStatDialog();
dform.setPtr(stats_obj);
dform.RunAppModal();
UPP::DeleteUsrLog();
UPP::AppExit__();

it works but when app closes (dll detach) i get message "heap leaks detected" (debug build).


The initialization of form is definitely not the problem.

However, the issue could be about how you have arranged for DLL. Do you use DLL_APP_MAIN?
Re: Creating a form inside a DLL [message #33907 is a reply to message #33905] Sat, 24 September 2011 21:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
tcler wrote on Sat, 24 September 2011 15:01

ok, next question. how to create custom sorting function for column in arrayctrl?
int cmpv(const Value& row1, const Value& row2)
{
	if (pureValue (String(row1)) > pureValue (String(row2))) return 0; else return 1;
}

function works fine, but sorting the table does not:
ExampleTable.ColumnAt(2).Sorting(cmpv);

access violation in Upp::sAC_ColumnSort::operator()(const Upp::Value & a, const Upp::Value & b):
ExampleTable.ColumnAt(2).Sorting(FnValueOrder(cmpv));

any ideas, please.


I am sorry, but there is too many variable not quoted in your post.

I suggest you to provide some minimal testcase (one complete enough to compile and run).

Mirek
Re: Creating a form inside a DLL [message #33908 is a reply to message #33907] Sat, 24 September 2011 22:23 Go to previous messageGo to next message
tcler is currently offline  tcler
Messages: 4
Registered: September 2011
Junior Member
mirek wrote on Sat, 24 September 2011 23:30

Do you use DLL_APP_MAIN?

no, i'm using upp only for building forms
mirek wrote on Sat, 24 September 2011 23:33


I suggest you to provide some minimal testcase (one complete enough to compile and run).

ok, i have attached example. project (dm plugin) sources: http://ompldr.org/vYWlnbA/StatPlugin.zip
  • Attachment: testapp.zip
    (Size: 1.66KB, Downloaded 197 times)
Re: Creating a form inside a DLL [message #33969 is a reply to message #33908] Sun, 02 October 2011 10:12 Go to previous message
tcler is currently offline  tcler
Messages: 4
Registered: September 2011
Junior Member
question still relevant.
upd.: solved. sorting class from ArrayCtrl.cpp:
struct sAC_ColumnSort : public ValueOrder {
	bool              descending;
	const ValueOrder *order;
	int             (*cmp)(const Value& a, const Value& b);

	virtual bool operator()(const Value& a, const Value& b) const {
		return descending ? cmp ? (*cmp)(b, a) < 0 : (*order)(b, a)
		                  : cmp ? (*cmp)(a, b) < 0 : (*order)(a, b);
	}
};

cmp function must return a negative value if value1 > value2 and positive if value1 < value2. why not true/false??

[Updated on: Tue, 04 October 2011 17:51]

Report message to a moderator

Previous Topic: Scatter: To find width bwt any two points.
Next Topic: gridctrl with sql
Goto Forum:
  


Current Time: Sat May 04 11:33:33 CEST 2024

Total time taken to generate the page: 0.01885 seconds