- HarlinnWindows-2015-01-03-01.zip
- Examples
- Windows
- Controls
- ButtonExample
- CheckBoxExample
- CommandButtonExample
- DropDownButtonExample
- HeaderControlExample
- LabelExample
- LinkLabelExample
- RadioButtonExample
- TextEditExample
- DateTime
- StopwatchExample2
- Graphics
- GDI
- DeviceContextExample
- Strings
- DotNetStringsExample
- StringsExample
- HarlinnDiagramLib
- HarlinnGraph
- HarlinnNumericsLib
- HarlinnPowerLib
- HarlinnWindows.sln
- HarlinnWindows
- HarlinnWindowsTest
- HarlinnWindows-2014-08-20-02.zip
|
#include "stdafx.h"
#include "DropDownButtonExample.h"
#include "hwinapplication.h"
#include "hwinform.h"
#include "hwinmenu.h"
#include "hwinstdctrls.h"
#include <iostream>
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
using namespace harlinn::windows;
class DropDownButtonForm : public Form
{
std::shared_ptr<DropDownButton> button;
public:
typedef Form Base;
DropDownButtonForm();
protected:
virtual void DoOnInitialize();
virtual void DoOnSize(Message& message);
virtual void DoOnPaint(Message& message);
};
DropDownButtonForm::DropDownButtonForm()
: Base()
{
SetText(L"DropDownButton example");
SetSize(300,70);
}
void DropDownButtonForm::DoOnInitialize()
{
Base::DoOnInitialize();
auto self = As<DropDownButtonForm>();
button = make_control<DropDownButton>(self);
button->SetText(L"Click me!");
button->OnClick.connect([&](Control* sender){ SetText(L"Button clicked"); });
auto firstItem = button->Menu()->AddMenuItem(L"First Item");
firstItem->OnClick.connect([&](MenuItem* sender){ SetText(L"First Item clicked"); });
auto secondItem = button->Menu()->AddMenuItem(L"Second Item");
secondItem->OnClick.connect([&](MenuItem* sender){ SetText(L"Second Item clicked"); });
}
void DropDownButtonForm::DoOnSize(Message& message)
{
harlinn::windows::Rectangle clientRect = GetClientRect();
button->MoveWindow(5,5,clientRect.Width()-10,21);
}
void DropDownButtonForm::DoOnPaint(Message& message)
{
Base::DoOnPaint(message);
auto dc = std::make_shared<PaintDeviceContextHandle>(As<Control>());
dc->DrawDesktopWallPaper();
}
int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
try
{
auto application = make_component<Application>();
auto form = make_control<DropDownButtonForm>();
auto result = application->Run(form);
return result;
}
catch(std::exception& exc)
{
std::cout << exc.what() << std::endl;
}
catch(...)
{
std::cout << "Unknown exception" << std::endl;
}
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Chief Architect - Sea Surveillance AS.
Specializing in integrated operations and high performance computing solutions.
I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.
Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...
A few Highlights:
- High performance application server development
- Model Driven Architecture and Code generators
- Real-Time Distributed Solutions
- C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
- Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
- AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
- Oracle WebLogic, IBM WebSphere
- Corba, COM, DCE, WCF
- AspenTech InfoPlus.21(IP21), OsiSoft PI
More information about what I do for a living can be found at:
harlinn.com or
LinkedIn
You can contact me at
espen@harlinn.no