torsdag den 26. maj 2011

Visual Studio (2008) windows forms - c++ - tab order

So, since I've changed jobs I'm now stuck in VS2008.

And let me clarify something:
I HATE IT!

It is worlds from eclipse which I used before, and in most respects I mean this in a bad way.
The UI is littered with menu/options that don't work, in one view or another.
The dialog boxes (even though they are named the same) change function wether you're running an application or not, or if you've open a specific view/explorer.

To make matters worse, I'm tasked with maintaining an application written in C++ and winforms.
Don't get me wrong here; I like C++, and have worked with it for over 5 years, building linux apps and Qt GUI's.

Take the simple task of defining the tab order in a form; its a complete pain.
I googled the topic, because (as usual) I could not find a option for it in VS.
I found this on msdn: How to: Set the Tab Order on Windows Forms
But surprise, surprise, IT DOES NOT WORK!
I don't have the options/views; Absolutely nowhere can I find "Tab Order".
Designer view? Nope stuck in code view as well, but that's another story.

All hope is not lost though.
Open a file browser, navigate to the .rc file that contains your dialog, or other gui element, and open it using notepad++ or some other editor.

Here's the interresting piece of code from the file I'm working:

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_SIGNIN DIALOG  0, 0, 210, 122
STYLE DS_SETFONT | WS_POPUP | WS_BORDER | WS_SYSMENU
FONT 10, "Microsoft Sans Serif"
BEGIN
    LTEXT           "Indtast Medarbejdernummer",IDC_LBL_LOGINNUMBER,68,18,135,13
    EDITTEXT        IDC_EDB_LOGINNUMBER,68,35,113,12,ES_AUTOHSCROLL | ES_NUMBER
    LTEXT           "Indtast Loginkode",IDC_LBL_LOGINCODE,67,53,136,13
    EDITTEXT        IDC_EDB_LOGINCODE,67,70,113,12,ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
END

There are two Labels (LTEXT), and two Editable text input boxes (EDITTEXT).
Tab order is determined by the order they are listed, so if I wanted to change it, I would simply change the order in which they are listed.
Just note that elements that does not take focus will be skipped, so the two labels does not affect the tab order.
Default focus is the first element in the list that takes focus.

Now save the file, and you're done.

Oh, and watch what happens to VS when it gets focus again.
It says the file has changed, and if you wish to reload it.
If you press "yes" here VS will stop working and get restarted by windows.



How to: Set the Tab Order on Windows Forms

søndag den 6. marts 2011

Linux: Running a command/script after resuming from sleep

I've got myself a Asus Eee Top 1602, which I really want to run linux (gentoo) on.

I've got most of the stuff on it working, both the touchscreen, audio and wifi.

There are two issues left:
 * The volume keys on the front don't work, and
 * after I resume from suspend, the display is dimmed to something like 50%.

Previous issues have been:
 * Getting the wifi to work, and
 * Getting the wifi to work after resume.

Things I haven't looked at yet:
 * Memory card reader

Let me just give the some info to the eee top 1602:
 # lspci
00:00.0 Host bridge: Intel Corporation Mobile 945GME Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GME Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 2 (rev 02)
00:1c.3 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 4 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 02)
00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)
00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 02)
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
02:00.0 Network controller: RaLink RT2860
# lsusb
Bus 001 Device 005: ID 0bda:0158 Realtek Semiconductor Corp. Mass Storage Device
Bus 001 Device 006: ID 0458:7063 KYE Systems Corp. (Mouse Systems)
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 1bfd:1688 TouchPack Resistive Touch Screen
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 04f2:0402 Chicony Electronics Co., Ltd
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub


Getting wifi to work
I'm using the staging driver in the kernel.
It's under: Device Drivers -> Staging drivers ->  Ralink 2860/3090 wireless support
You can compile it as a module or built it into the kernel, it dosen't matter.
What matters, is that you go go Ralink's website, and download the firmware file rt2860.bin, otherwise you'll just get something like this in dmesg when you "up" the wifi:
eeeTop kernel: [ 1321.424360] rt2860 0000:02:00.0: firmware file rt2860.bin request failed (-2)
eeeTop kernel: [ 1321.424378] ERROR! NICLoadFirmware failed, Status[=0x00000001]
eeeTop kernel: [ 1321.424397] rt28xx Initialized fail!

You'll find that here: http://www.ralinktech.com/support.php?s=2 and you'll need to get the PCI firmware of course.
Download that, extract, and place it under /lib/firmware (you might have to create the directory).

After this, I just emerged wpa_supplicant, and I'm able to connect to my wifi (WPA2 protected).

Getting wifi to work after resume
I found out that after the machine has been put in suspend, and reawaken, the wifi does work reconnect.
wpa_supplicant still reports the wifi as connected (with an IP adress and all that, but there's no connection).
I've read some people have some success by disabling some kernel options (specifically wireless extensions), but that  did not work for me.
Instead 'm just restarting the wifi after the machine resumes.
First I thought of using acpid, but I could not find see that that reports any suspend/resume events.
Anyway acpi is old, and maybe deprecated, now with hal (which is also deprecated) and policykit/consolekit, the last one being the future.
I've moved the system completely over to consolekit/policykit, and it work 100% now. (power management, shutdown, suspend, hibernate). But how to migrate was not that well documented, but thats a different story.

I found the solution to be pm-utils.
Even though it is written for HAL, it seems to work for consolekit as well.
Best of all, it is very easy to setup.
Under /etc/pm/ you'll find the configuration.

Under /etc/pm/sleep.d/ I just made a new file 50wifi, and put this in it:
#!/bin/bash
case $1 in
   hibernate)
       echo "Hibernating"
       ;;
   suspend)
       echo "Suspending"
       ;;
   thaw)
       echo "Returning from hibernation"
       /etc/init.d/net.wlan0 restart
       ;;
   resume)
       echo "Returning from suspend"
       /etc/init.d/net.wlan0 restart
       ;;
esac

Next, just make the file executable:
# chmod +x /etc/pm/sleep.d/50wifi

And thats it.
Now, every time the computer comes back from suspend or hibernation it restarts my wireless, and my connection is back within seconds.

I might update the blog, once I the re two remaining issues resolved.
I can live without the volume keys, but the dimmed display really needs to be fixed.

tirsdag den 15. februar 2011

Mini-itx cases, why is it so hard to find one that fits your needs?

Ok, so I've bought myself a new computer, this is going to be my "master" computer (which includes some gaming), and since I'm a little nuts I've decided that it should be as small as possible.
This means mini-itx!

However, it's not much fun having a high performance pc, and use on-board graphics, since these chips are usually only good for 2D and very light 3D.
So I also need room for a PCI-e graphics card and hence a somewhat powerful power-supply.

Lets just look at the PSU for a moment.
I'm using a Intel core i5-2500K and a Intel DH67CF motherbaord, spec'ed with 8 gb of kingston ram, with this I'm using a Consair P128 SSD.
This means a power draw between 35 and 130 watts.

None of the cases I've seen comes with a PSU thats near powerful enough (typically they're around 60W), but bying a picoPSU-150-XT would do the trick.

Now, what happens when I add a graphics card?
Ouch!
Here, no small PSU can be of any help :-(

This is especially true, when the card I'm going to use (for the moment) is a nVidia 8800GTS, which usesalot of power in idle, and much more when under load.
I really don't want to add ~100 watts to this system, since:
  1. It'll add another fan with all the noise thats brings.
  2. More heat, and I really don't want this in a small case.
  3. My energy bill will be much higher.

Well, for me, only one solution comes to mind. Plug in the graphics card when I want to do serious gaming, and leave it disconnected for my everyday computer-use.

I don't game that much. I do some programming, and gimp'ing, but the built-in Intel HD3000 graphics can handle this just fine.

Offtopic: Taking of power, did you know that most power-supplies are most effective at around 80% load?

So a picoPSU-150-XT for everyday use, and something else for gaming, or maybe just use a silverstone ST45SF PSU for it all.

If these where my only requirements for a case I would be fine, because there are lots of (mostly square) boxes that uses SFX PSU's and has room for a dual PCI-e card.

The problem is, that I really want a slim desktop case that sits under my monitor.
Now, by slim I mean less then 70mm!

I started my search at mini-itx.com/store, but found no cases that were up to the task.
So what candidates have I found?

Gigabyte
Gigabyte makes a series thats called MIB, I like the MIB T5142. Here are some images:

Now, I didn't notice this at first, but look at the last picture (of the back). Look how the motherboard is placed. Where is the PCI-e connector placed?
Thats right, all the way to the right, right next to the case edge (and no riser card/extension calbe I've found can reach).
Ok, there's no slot for the graphics card either, but I own a dremel, so thats no problem. I've cut these kinds of holes before.

I like the design, and the idea that the monitor is a part of it.
There is also ample room inside for a bigger power supply, harddrive and cdrom.
These cases are (WxDxH): 445 x 250 x 65  mm

Unfortunately, the MIB T5142 is not sold in eurupe, only the T5140:

But I don't like the front.
If I wanted this, I would move the motherboard to the left so a normal angled riser card would do the trick.

Then I found the Jetway JC-110-B:


I don't think it is as pretty, but it has the motherboard in the right place, and it's much smaller.
In fact, it's only (WxDxH): 300 x 273 x 65  mm
Jetway also makes two other models with the same sizes, but different fronts.
The jetway cases comes with a set of brackets to mount the case under your table or on the wall, which I think is a plus, because the case is too small for my monitor stand to fit on top of it.
On the down side, there's no audio port the the front/sides.

Silverstone cases:
There's the LC09:

It's 346 mm (W) x 55 mm (H) x 310 mm (D).
It has audio/usb in the side, and the motherboard in the right place, but I don't like the how the top plate looks. Why does it have to stick out over the rest of the case like that?
Also, given it's only 55mm high, I might not be able to fit the SFX PSU in there...
Oh, and lastly, the expansion port is only 1, which might not work with the dual design of the 8800GTS I have.

Then, there's the LC05:
Which is 346 mm (W) x 55 mm (H) x 300 mm (D).
But there's no expansion port(s), and the motherboard is placed wrong, like the MIB T5140/2.

Lastly there's the LC19:
It is 390 mm (W) x 68 mm (H) x 348 mm (D), and also available in black.
It's so large it can take a microATX motherboard.
There's audio, usb and card reader in the front (under the cover).
My only problem with this is, that it's deep. Almost 35 cm!

G-Atlantic
The GA620iBK-P4:

(with wall mount)


There are 3 different fronts for the case, the above in model A, which I quite like.
It's 300 (W) x 65 (H) x 273 (D) and comes with a 120W PSU (so I might not need the picoPSU)

There's also the GA630iBK-P4, which as far as I can are the same, but with a curved front:

or if you don't need the expansion ports, but want a smaller case, go with the GA688iBK-P4:

at only 220 (W)  x 65 (H) x 305 (D) mm


Casetronic
There's the c137:

 and the c158:

For info, see the chart below.
I think the finish is nice, but very industrial.
The c158 is just 54mm high, which might be a problem.

Here all info in a nice chart:

manufacture model h w d psu (w) cdrom exp fa fu cr type tag
gigabyte mib t5142 65 445 250 65 normal 0 y y n Mini-itx -eu
gigabyte mib t5140 65 445 250 65 normal 0 y y n Mini-itx
jetway  JC-110-B 65 300 273 100 slim 2 n y n Mini-itx
silverstone lc19 68 390 348 120 slim 1 y y y Micro-atx
silverstone lc05 55 346 300 60 normal 0 y y n Mini-itx
silverstone lc09 55 346 310 60 slim 1 y y n Mini-itx
Morex  2799 p4 64 295 288 150 slim 2 y y n Mini-itx ugly
Coolermaster Elite 100  70 262 318 150 slim 0 y y n Micro-atx
Casetronic c137 69 323 254 120 slim 2 n n n Mini-itx
Casetronic c158 54 305 279 120 slim 2 y y cf Mini-itx
G-alantic GA620iBK-P4 65 300 273 120 slim 2 n y n Mini-itx
h = height (mm)
w = width (mm)
d = depth (mm)
exp = full height expansion ports/brackets
fa = front audio jacket
fu = front usb port(s)
cr = card reader

The table became a little less readable because blogspot cropped the last text, so I had to shorten the whole table.


There are many others, but some simply look too flimsy, or are to high.
Search ebay for "mini-itx cases" and be inspired :-)

Other manufactures that makes products that almost fit my needs:
Evercase
Morex
Thermaltake
InWin
Chenbro


So, as it turns out, it isn't hard at all, your just need to know where to look.

I going with a G-Alantic GA6?0iBK-P4 or one of the casetronic's, as they look nice, has the size I'm going for, has a decent power supply I can use for everyday use, has the expansion port(s) I need.

Good hunting.