tag:blogger.com,1999:blog-66174346508240952532024-03-05T22:55:50.087-08:00Strix Code BlogThis is our blog with information about our products, articles on programming and UX design.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-6617434650824095253.post-45531180396880988682011-01-27T07:39:00.000-08:002011-01-27T07:46:42.839-08:00How to find the position of a taskbar button on Windows 7 or VistaIn this article I'm going to show you how to find the position of your application's taskbar button on the Windows 7 taskbar. The example code is Qt/C++ but it easy to adapt it for another language.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDs2upazDgBU04ajGoNW42ILPAAO0qT4Ax3Pv-qqZs4lzY2IA3HjPkF7-MZeP3dg28ENGPB-Co8FDp7GKGUuHaWIW1HtetpCg2UFW7dhs-WpULWmIiL9AwfE0Dk0homNS9VAEaFHwrAA/s1600/Intro.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="117" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDs2upazDgBU04ajGoNW42ILPAAO0qT4Ax3Pv-qqZs4lzY2IA3HjPkF7-MZeP3dg28ENGPB-Co8FDp7GKGUuHaWIW1HtetpCg2UFW7dhs-WpULWmIiL9AwfE0Dk0homNS9VAEaFHwrAA/s400/Intro.png" width="306" /></a></div>First of all we have to find the taskbar window (its HWND). We do this by searching for a specific window class:<br />
<pre class="prettyprint lang-cpp">HWND hwndTrayWnd = ::FindWindowW(L"Shell_TrayWnd", NULL);
</pre>Then we must find a child window which contains all the buttons:<br />
<a name='more'></a><br />
<pre class="prettyprint lang-cpp">HWND hwndTaskList = 0;
::EnumChildWindows(hwndTrayWnd, EnumShellWindows, (LPARAM)&hwndTaskList);
</pre>This functions is used to enumerate child windows:<br />
<pre class="prettyprint lang-cpp">static CALLBACK BOOL EnumShellWindows(HWND hwnd, LPARAM userParam)
{
wchar_t buffer[255];
HWND *hwndTaskList = (HWND *)userParam;
GetClassNameW(hwnd, buffer, sizeof buffer);
if (std::wstring(buffer) == L"MSTaskListWClass") {
*hwndTaskList = hwnd;
return FALSE;
}
return TRUE;
}
</pre>Now things start to be more tricky. The buttons aren't actual controls (windows), they are just pictures drawn on the taskbar. It means that we cannot enumerate and compare them. We have to capture the screen and analyze it. Thanks to Qt taking a capture of any windows is a one liner:<br />
<pre class="prettyprint lang-cpp">QImage taskListImage = QPixmap::grabWindow(hwndTaskList).toImage();
</pre>Finding a button for an active window is easy, because an active button has a light border around it with a few white pixels just below the top-left corner:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiST3jRnB0ZpyCGE79aRx8-i-tpv3hzwVDkTq-L-GEoMkmGSPeEkz38X7-Znnj5AQ4fuy2cNxYy2AE7vDxR7deM0asulPF7QwUcoxOihENXAv9EnpqI5gwsdl6lmW0_5filGMOFxc26ow/s1600/active+button.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="67" width="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiST3jRnB0ZpyCGE79aRx8-i-tpv3hzwVDkTq-L-GEoMkmGSPeEkz38X7-Znnj5AQ4fuy2cNxYy2AE7vDxR7deM0asulPF7QwUcoxOihENXAv9EnpqI5gwsdl6lmW0_5filGMOFxc26ow/s400/active+button.png" /></a></div>It means that if our windows is the active one we just have to find a button with the white pixels.<br />
<pre class="prettyprint lang-cpp">static int findActiveButtonX(const QImage& tasklistImage)
{
const QRgb white = qRgb(255, 255, 255);
for (int x = SPACING; x < tasklistImage.width(); x += (BUTTON_WIDTH + SPACING)) {
if (tasklistImage.pixel(x, ROUND_CORNER_HEIGHT) == white) {
return x;
}
}
return -1;
}
</pre>
If we are looking for an inactive button then there is no other way but to compare the icons.
<pre class="prettyprint lang-cpp">static int findInactiveButtonX(const QIcon& appIcon, const QImage& tasklistImage)
{
QImage iconImage = appIcon.pixmap(32, 32).toImage();
for (int x = SPACING; x < tasklistImage.width(); x += (BUTTON_WIDTH + SPACING)) {
QImage otherIcon = tasklistImage.copy(x + ICON_LEFT_MARGIN, ICON_TOP_MARGIN, 32, 32);
if (compareImages(iconImage, otherIcon))
return x;
}
return -1;
}
static bool compareImages(const QImage& a, const QImage& b)
{
for (int x = 0; x < a.width(); ++x) {
for (int y = 0; y < a.height(); ++y) {
QRgb rgb = a.pixel(x, y);
// Test only opaque pixels
if (qAlpha(rgb) == 255) {
if (rgb != b.pixel(x, y))
return false;
}
}
}
return true;
}
</pre>
When we have the x position of our button within the taskbar list window, then the last step is to convert this value to global (screen) coordinate:
<pre class="prettyprint lang-cpp">::RECT rect;
::GetWindowRect(hwndTaskList, &rect);
QRect buttonRect(rect.left + buttonX, rect.top + 1, BUTTON_WIDTH, BUTTON_WIDTH);
</pre>And that's it. Now we can for example display a notification directly above the taskbar button making it look more logical to the user.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com1tag:blogger.com,1999:blog-6617434650824095253.post-60553347601428154272011-01-25T01:23:00.000-08:002011-02-26T03:57:49.718-08:00J7Goodies version 1.0.6 released<span class="Apple-style-span" style="font-family: inherit;"><a href="http://www.strixcode.com/j7goodies/">J7Goodies</a> version 1.0.6 has been released. This version brings the following improvements.</span><br/><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0oKB8e1E-o1LFr8JDB1baAchOa1vk0dgg00-MENmcGWojR-K-wU_a45cl2dKBNSTWrJzZiS_bQ3b41pxIjoXABYyQ7eH8XJuhfozQfHV-sibB9j7130NVmii-nkTYMXGm8gVr-rDp0g/s1600/q7goodies-white-bg.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="206" width="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0oKB8e1E-o1LFr8JDB1baAchOa1vk0dgg00-MENmcGWojR-K-wU_a45cl2dKBNSTWrJzZiS_bQ3b41pxIjoXABYyQ7eH8XJuhfozQfHV-sibB9j7130NVmii-nkTYMXGm8gVr-rDp0g/s400/q7goodies-white-bg.png" /></a></div><span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit; font-size: large;">1. Improved native library unloading.</span><br />
Now the ClassLoader is forced at application exit to unload the native library. This should prevent a rare situation when the native library was kept in the temp directory.<br />
<br />
<span class="Apple-style-span" style="font-size: large;">2. Keeping the thumbnail toolbar </span><span class="Apple-style-span" style="font-size: large;">visible</span><span class="Apple-style-span" style="font-size: large;">.</span><br />
When you hide and then show again a window that has a thumbnail toolbar then the toolbar will stay hidden. This is how Windows 7 works. Now you can show the toolbar again be calling it's <span class="Apple-style-span" style="font-family: "Courier New", "Courier", monospace;">show()</span> method (only after your window is visible).<br />
<br />
<span class="Apple-style-span" style="font-size: large;">3. Detecting when a taskbar button is created.</span><br />
When you hide and show your application window then its taskbar button is destroyed and recreated every time. You cannot access the button until it is created and sometimes it happens some time after the window became visible. Now you can be informed about this event by adding a <span class="Apple-style-span" style="font-family: "Courier New", "Courier", monospace;">TaskbarButtonListener</span> to your <span class="Apple-style-span" style="font-family: "Courier New", "Courier", monospace;">TaskbarButton</span>.<br />
<pre class="prettyprint lang-java">taskbarButton.addTaskbarButtonListener(new TaskbarButtonListener() {
public void taskbarButtonCreated(TaskbarButtonEvent tbe) {
thumbnailToolBar.show();
}
});
</pre><span class="Apple-style-span" style="font-family: inherit; font-size: large;">4. New license manager.</span><br />
The license verification code has been rewritten. Previously license files were encrypted. Now they are plain-text files. This will help to spot a situation when someone steals your license and uses it in his/her own application.<br />
<div><br />
<span style="font-size: large;">5. Fixed TaskbarButton.isSupported()</span><br />
This method was throwing UnsatisfiedLinkError instead of returning false when was not supported.</div><br />
<span style="font-size: large;">6. Performance improvements for thumbnails and live previews</span><br />
Now the code that deals with window thumbnails and live previews is more efficient. <br />
<br />
<span style="font-size: large;">7. Native library has been refactored</span><br />
The native library has been refactored so now it should be more reliable and efficient.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com0tag:blogger.com,1999:blog-6617434650824095253.post-46460669580271278272011-01-04T04:01:00.000-08:002011-01-10T04:34:49.194-08:00Introducing SevenBeans: NetBeans Windows 7 integration module<span class="Apple-style-span" style="line-height: 18px;"><span class="Apple-style-span" style="font-family: inherit;"><a href="http://www.strixcode.com/sevenbeans/">SevenBeans</a>, a module for NetBeans IDE (or any other NetBeans Platform application), provides all Windows 7 taskbar extensions, excluding the thumbnail toolbar. First of all, <a href="http://www.strixcode.com/sevenbeans/">SevenBeans</a> allows you to pin NetBeans IDE to the taskbar. This is very handy if you use the taskbar a lot. Unfortunately, Java applications cannot be pinned to the taskbar so <a href="http://www.strixcode.com/sevenbeans/">SevenBeans</a> makes a difference here. When you click a taskbar button for NetBeans IDE, a jump list appears:</span></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://www.strixcode.com/sevenbeans/img/jumplist.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.strixcode.com/sevenbeans/img/jumplist.png" /></a></div><span class="Apple-style-span" style="line-height: 18px;"><span class="Apple-style-span" style="font-family: inherit;"><br />
</span></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://netbeans.dzone.com/sites/all/files/jumplist.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: inherit;"></span></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="line-height: 18px;"></span></span></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 1.2em; margin-left: 0px; margin-right: 0px; margin-top: 0.6em; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="font-family: inherit;">It contains your recent projects, so you can open them directly. There are also shortcuts for a new project and a new file.</span><br />
<a name='more'></a></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 1.2em; margin-left: 0px; margin-right: 0px; margin-top: 0.6em; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="font-family: inherit;">Also, <a href="http://www.strixcode.com/sevenbeans/">SevenBeans</a> displays NetBeans task progress on the taskbar button, so that you can see at a glance when a build process is finished, etc.</span></div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.strixcode.com/sevenbeans/img/progressbar.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.strixcode.com/sevenbeans/img/progressbar.png" /></a></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 1.2em; margin-left: 0px; margin-right: 0px; margin-top: 0.6em; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="font-family: inherit;"><br />
</span></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 1.2em; margin-left: 0px; margin-right: 0px; margin-top: 0.6em; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="font-family: inherit;"></span>When you are running, debugging, or building a project, a small overlay icon is shown on the taskbar button, so that you can see the NetBeans status at all times:</div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.strixcode.com/sevenbeans/img/magnifier.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.strixcode.com/sevenbeans/img/magnifier.png" /></a></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 1.2em; margin-left: 0px; margin-right: 0px; margin-top: 0.6em; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="line-height: 18px;">It also has the the ability to create tabbed thumbnails for open documents, exactly like what Internet Explorer does for open tabs:</span></div><div class="separator" style="clear: both; text-align: center;"><a href="http://netbeans.dzone.com/sites/all/files/tabbed-thumbnails.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: inherit;"></span></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.strixcode.com/sevenbeans/img/tabbed-thumbnails.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.strixcode.com/sevenbeans/img/tabbed-thumbnails.png" /></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="line-height: 18px;"><span class="Apple-style-span" style="font-family: inherit;"><br />
</span></span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="line-height: 18px;"><span class="Apple-style-span" style="font-family: inherit;">The tabs are all updated in real time, so that you can close a document by closing its thumbnail, etc. However, this feature is disabled by default, since if you have many open documents, navigating through the thumbnails becomes a hassle:</span></span></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.strixcode.com/sevenbeans/img/options.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.strixcode.com/sevenbeans/img/options.png" /></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: arial, verdana, helvetica, sans-serif; font-size: 12px; line-height: 18px;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: arial, verdana, helvetica, sans-serif; line-height: 18px;"><span class="Apple-style-span" style="font-size: large;"><b><br />
</b></span></span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: arial, verdana, helvetica, sans-serif; line-height: 18px;"><span class="Apple-style-span" style="font-size: large;"><b>The technology behind it</b></span></span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: arial, verdana, helvetica, sans-serif; line-height: 18px;"><span class="Apple-style-span" style="font-size: large;"><b><br />
</b></span></span></div><a href="http://www.strixcode.com/sevenbeans/">SevenBeans</a> uses <a href="http://www.strixcode.com/j7goodies/">J7Goodies</a> - a Java library that provides all Windows 7 features in a developer friendly way. This is a very good product, I put a lot of effort into it so developers using <a href="http://www.strixcode.com/j7goodies/">J7Goodies</a> can integrate Windows 7 functionality with their application in just a few lines of code.<br />
<br />
Having the <a href="http://www.strixcode.com/j7goodies/">J7Goodies</a> library, I was looking for a way to showcase its abilities and I wanted it to be a real world example. Because I'm using NetBeans, which is a great IDE and even greater rich-client platform, I came up with the idea that I could improve the NetBeans experience on Windows 7 and showcase my library at the same time. I believe that it was a good idea because <a href="http://www.strixcode.com/sevenbeans/">SevenBeans</a> user base is growing at an incredibly fast pace and it is getting a very good feedback.<br />
<br />
<span class="Apple-style-span" style="font-size: 12px; line-height: 18px;"><span class="Apple-style-span" style="font-family: inherit;"><br />
</span></span>Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com0tag:blogger.com,1999:blog-6617434650824095253.post-78217659020147177602010-12-14T05:39:00.000-08:002010-12-14T07:02:48.293-08:00We are now a Nokia Qt Ambassador<h3 class="title" style="clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="font-family: inherit; font-size: small; font-weight: normal;">We are happy to announce that we have become an official Nokia Qt Ambassador. This is very flattering for us because Nokia's Qt is our technology of choice as it emerges as the most sophisticated C++ framework available.</span></h3><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4vSQv5DO3HHLEYEe5lemZlayA86YmgkMFaY61VaF0C_voUDlPBP3BHIIylOoJUdgh2ytqfXRIfgZipfYxSGrAKNHgQSlzT7zHIHKGO7U7eql_DrJ81HY6M5_zE5FFCZu2QcekCaPtiw/s1600/qt_ambassador_logo-no-background-256.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4vSQv5DO3HHLEYEe5lemZlayA86YmgkMFaY61VaF0C_voUDlPBP3BHIIylOoJUdgh2ytqfXRIfgZipfYxSGrAKNHgQSlzT7zHIHKGO7U7eql_DrJ81HY6M5_zE5FFCZu2QcekCaPtiw/s1600/qt_ambassador_logo-no-background-256.png" /></a></div><div><span class="Apple-style-span" style="color: #404040; font-family: Helvetica, Arial, sans-serif;"><span class="Apple-style-span" style="font-size: 21px; font-weight: normal;"><br />
</span></span></div>Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com1tag:blogger.com,1999:blog-6617434650824095253.post-27645554624210275092010-12-03T06:58:00.000-08:002010-12-14T07:02:03.704-08:00Our new product: J7GoodiesToday we are releasing another product for Windows 7 integration. <a href="http://www.strixcode.com/j7goodies/">J7Goodies</a> is a Java library that provides Windows 7 features like jump list, taskbar thumbnails, thumbnail toolbar and more, the Java way. This is a complete package, it does everything you can think of in terms of the new Windows 7 taskbar extensions.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com3tag:blogger.com,1999:blog-6617434650824095253.post-89811498087984946072010-11-14T09:25:00.000-08:002010-11-14T09:27:24.698-08:00Sketch - an unbloated sketching app releasedWe are happy to announce the release of <a href="http://www.strixcode.com/sketch/">Sketch</a> - a simple application for drawing drafts. <b>Stop fine-tuning your drafts and get the job done.</b> Finally a prototyping application that focuses on productivity. <a href="http://www.strixcode.com/sketch/">Sketch</a> by its simplicity forces you to think about the big picture.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL-KR_OQHvuS9Hhjfg9R4UpAtk3kuoLHG4c3JgEVpN_QVKuTW1QSu9vo6Kw_gtJ-OVol5bupttKWB2H0gDA-EyJ3iH7Z56dUVRxSeMWNU2RnLBO3eGoC05rpEkOcYI6FLdwnHrCQG8MQ/s1600/Sketch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="302" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL-KR_OQHvuS9Hhjfg9R4UpAtk3kuoLHG4c3JgEVpN_QVKuTW1QSu9vo6Kw_gtJ-OVol5bupttKWB2H0gDA-EyJ3iH7Z56dUVRxSeMWNU2RnLBO3eGoC05rpEkOcYI6FLdwnHrCQG8MQ/s320/Sketch.png" width="320" /></a></div>Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com1tag:blogger.com,1999:blog-6617434650824095253.post-1571345587029848282010-09-28T06:47:00.000-07:002010-09-28T06:47:48.637-07:00How to connect a Samsung Syncmaster P2270HD to your PC with a HDMI cableIf you connect a Samsung Syncmaster to your PC/laptop using a HDMI cable the quality isn't very good. It looks a little blurry. It took me a lot of research to find the solution.<br />
<br />
You have to go to the Source menu in your Samsung, then choose Rename and select a PC as the name. After this you will get a crystal clear picture.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com8tag:blogger.com,1999:blog-6617434650824095253.post-31417963610756714152010-09-15T02:53:00.000-07:002010-09-15T03:06:56.995-07:00Q7Goodies evaluation version releasedWe just created and uploaded an evaluation version of <a href="http://www.strixcode.com/q7goodies/">Q7Goodies</a>. This version has the same features as the full one but it works only for 30 days and appends the 'Q7Goodies' string to window title, jump list entries, taskbar thumbnail title, etc.<br />
<br />
The evaluation version contains dynamic and static libraries for both: Microsoft Visual C++ and MinGW (QtCreator). There are also two demo applications and their source code. The header files are self-contained, it means that you don't need to install the Windows 7 SDK.<br />
<br />
Ok, where to download it? Just go to the <a href="http://www.strixcode.com/q7goodies/demos">demos</a> section.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com2tag:blogger.com,1999:blog-6617434650824095253.post-41648553531541399702010-08-11T08:13:00.002-07:002011-01-10T04:37:21.470-08:00Embedding Application Manifest and Version Information using QtCreatorModern applications for Microsoft Windows should include an embedded manifest and version information. The version information is used for example by the UAC dialog and it is displayed in Explorer's file properties. The manifest is even more important because without it Vista and Windows 7 will virtualize your application's access to the registry and file system. Unfortunately it is not obvious how to embed such information using QtCreator, so we publish this post in hope it will save you time.<br />
<br />
<span style="font-size: large;"><b>Application Manifest</b></span><br />
<br />
First, we have to prepare an application manifest file. This one below is for application that does not require administrator rights:<br />
<br />
<pre class="prettyprint lang-xml"><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="2.0.2.0" processorArchitecture="X86" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly></pre>Second, we need the MT.exe tool from the Microsoft Windows SDK to embed this XML in our executable. To do it use the following command:<br />
<pre>mt.exe –manifest MyApp.exe.manifest -outputresource:MyApp.exe;1</pre><span style="font-size: large;"><b></b></span><br />
<a name='more'></a><span style="font-size: large;"><b>Automatic Manifest Embedding</b></span><br />
<br />
Manually executing the mt command after each compilation is a tedious task. What about convincing qmake to do it for us? After studying the docs it looks like the following line should do the trick:<br />
<br />
<pre>win32 {
WINSDK_DIR = C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A
WIN_PWD = $$replace(PWD, /, \\)
OUT_PWD_WIN = $$replace(OUT_PWD, /, \\)
QMAKE_POST_LINK = "$$WINSDK_DIR/bin/x64/mt.exe -manifest $$quote($$WIN_PWD\\$$basename(TARGET).manifest) -outputresource:$$quote($$OUT_PWD_WIN\\${DESTDIR_TARGET};1)"
}
</pre>The above code will automatically execute the mt.exe program from WINSDK_DIR and embed a manifest file that is located in the project root directory and named after project's target (ie. MyApp.manifest). That's all to adding a manifest, now let's move on and specify the version information.<br />
<span style="font-size: large;"><b>Version Information</b></span><br />
<br />
VERSIONINFO is in fact a resource, so put the following in your resource file (ie. MyApp.rc):<br />
<br />
<pre>1 VERSIONINFO
FILEVERSION 0,0,0,1
PRODUCTVERSION 0,0,0,1
FILEOS 0x4
FILETYPE 0x0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "MyCompany"
VALUE "FileDescription", "My cool app"
VALUE "FileVersion", "0,0,0,1"
VALUE "InternalName", "MyApp"
VALUE "LegalCopyright", "Copyright © 2010 MyCompany"
VALUE "OriginalFilename", "MyApp.exe"
VALUE "ProductName", "MyApp"
VALUE "ProductVersion", "0,0,0,1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END</pre>The above example should be sufficient in most cases, for more information about version information resource syntax please refer to the official <a href="http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx">MSDN documentation</a>. <b>Qmake</b> will process your resource file if you add it to your project (.pro) file:<br />
<pre>RC_FILE = MyApp.rc</pre>And that's all. Now your application is ready to be deployed to a Windows system.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com5tag:blogger.com,1999:blog-6617434650824095253.post-65427036339550849172010-08-03T09:10:00.000-07:002010-08-03T09:10:52.705-07:00Our company has received funding from the European UnionWe are very happy to announce that our company has received funding from the European Union. The money come from the Human Capital National Cohesion Strategy within the European Social Fund. We hope to put the funds to good use that will allow Strix Code to grow and introduce a few more interesting products.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com0tag:blogger.com,1999:blog-6617434650824095253.post-43496896277293335472010-06-05T03:57:00.000-07:002010-06-05T03:59:07.977-07:00Luabind converter for QStringLuabind is a very convenient tool for binding C++ code to Lua. If you want to use Lua inside your Qt project then support for QString type is a must. By adding a little C++ template you can teach Luabind how to convert between QString and Lua string types. Just copy and paste the following code.<br />
<pre class="prettyprint lang-cpp">namespace luabind
{
template <>
struct default_converter<qstring>
: native_converter_base<qstring>
{
static int compute_score(lua_State* L, int index)
{
return lua_type(L, index) == LUA_TSTRING ? 0 : -1;
}
QString from(lua_State* L, int index)
{
return QString(lua_tostring(L, index));
}
void to(lua_State* L, QString const& x)
{
lua_pushstring(L, x.toAscii());
}
};
template <>
struct default_converter<qstring const&>
: default_converter<qstring>
{};
}</pre>Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com5tag:blogger.com,1999:blog-6617434650824095253.post-43884051203216483412010-05-10T23:36:00.000-07:002010-12-20T04:34:59.468-08:00Windows 7 or Vista UAC Shield Icon in Qt(For a way to embed an application manifest with QtCreator see <a href="http://blog.strixcode.com/2010/08/embedding-application-manifest-and.html">here</a>)<br />
<br />
In a Qt application you cannot use the BCM_SETSHIELD message to show the UAC shield icon on a QWidget. This is because Qt does its own painting. The good news is that, it is very simple to access this icon in Qt.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSgxcvbFQHMIzyMdB3qORWdIuggKKiFhjcNZAyGeQx2Suad14ZkakOWNyiUBx8ERcBRATfGG_Oh9g1QNj0yPNZnKwG4gv1c_kBXP33RqeiPPyJnrv8S_SqlWTyr9WZYbO_rmYizggejg/s1600/UAC_Shield_Icon_in_Qt.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5469905056259023202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSgxcvbFQHMIzyMdB3qORWdIuggKKiFhjcNZAyGeQx2Suad14ZkakOWNyiUBx8ERcBRATfGG_Oh9g1QNj0yPNZnKwG4gv1c_kBXP33RqeiPPyJnrv8S_SqlWTyr9WZYbO_rmYizggejg/s400/UAC_Shield_Icon_in_Qt.png" style="cursor: hand; cursor: pointer; display: block; height: 162px; margin: 0px auto 10px; text-align: center; width: 271px;" /></a><br />
<pre class="prettyprint lang-cpp">QIcon icon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
pushButton->setIcon(icon);
commandLinkButton->setIcon(icon);
</pre><br />
The above code will return null icon on systems older then Windows Vista.<br />
If you are developing for Windows 7 then check out <a href="http://www.strixcode.com/q7goodies/">Q7Goodies</a> - a Qt add-on that provides <b>Windows 7</b> features like jump list, taskbar thumbnails, thumbnail toolbar and more in a Qt way. It integrates seamlessly with existing applications by using Qt design patterns and API style. It comes with the full s<b>ource code</b> and a<b> royalty-free license</b>.Strix Codehttp://www.blogger.com/profile/00724837629589894642noreply@blogger.com0