|
#include <iostream>
using namespace std;
int main() {
cout << (unsigned char)0x07 << endl;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
hi.
using MessageBeep(-1) did the trick. thanks for helping, you're all great. if you happen to know a way to control the length of the beep (so i won't have to use a loop) it would be great.
and thanks.
|
|
|
|
|
Has anybody managed to get the grouping working with the list control (as seen in My Computer as it separates your hard drives from your CD ROMs for example)?
It feels like I have been banging my head against a brick wall all afternoon trying to get it to work with no joy.
I have created a new project with VS 2002 so I assume all the manifest requirements have been met.
I then get the list control from the CListView and add a group using the InsertGroup() function.
I then insert two items using the InsertItem() function and for each item I set the Group ID to the corresponding group.
This is the code I have so far. I would be eternally grateful if someone could point out what I am not doing correctly or have failed to do all together.
//Get the listCtrl from the View
CListCtrl& ctrl = GetListCtrl();
//View control in icon veiw
ctrl.ModifyStyle(0, LVS_ICON);
//Enable the Group View so we can group the entries
ctrl.EnableGroupView(TRUE);
//Add a Column
ctrl.InsertColumn(0, "Name");
ctrl.SetColumnWidth(0, 300);
//Add the groups to the control
LVGROUP* pGroup = new LVGROUP;
if(pGroup != NULL)
{
ZeroMemory(pGroup, sizeof(LVGROUP));
pGroup->cbSize = sizeof(LVGROUP);
pGroup->mask = LVGF_HEADER | LVGF_ALIGN | LVGF_STATE | LVGF_GROUPID;
pGroup->pszHeader = L"Coordinate Reference Systems";
pGroup->cchHeader = 28;
pGroup->stateMask = 0;
pGroup->state = LVGS_NORMAL;
pGroup->uAlign = LVGA_HEADER_LEFT;
pGroup->iGroupId = 0;
LRESULT res = ctrl.InsertGroup(0, pGroup);
TRACE("Group added");
}
//Add a second group
LVGROUP* pGroup2 = new LVGROUP;
if(pGroup2 != NULL)
{
ZeroMemory(pGroup2, sizeof(LVGROUP));
pGroup2->cbSize = sizeof(LVGROUP);
pGroup2->mask = LVGF_HEADER | LVGF_ALIGN | LVGF_STATE | LVGF_GROUPID;
pGroup2->pszHeader = L"Coordinate Reference Systems";
pGroup2->cchHeader = 28;
pGroup2->stateMask = 0;
pGroup2->state = LVGS_NORMAL;
pGroup2->uAlign = LVGA_HEADER_LEFT;
pGroup2->iGroupId = 1;
LRESULT res = ctrl.InsertGroup(1, pGroup2);
TRACE("Group added");
}
//Add a couple of items
LVITEM* pLVItem = new LVITEM;
ZeroMemory(pLVItem, sizeof(LVITEM));
pLVItem->mask = LVIF_GROUPID | LVIF_TEXT;
pLVItem->iItem = 0;
pLVItem->iGroupId = 0;
pLVItem->pszText = _T("Andy");
pLVItem->cchTextMax = 4;
ctrl.InsertItem(pLVItem);
LVITEM* pLVItem2 = new LVITEM;
ZeroMemory(pLVItem2, sizeof(LVITEM));
pLVItem2->mask = LVIF_GROUPID | LVIF_TEXT;
pLVItem2->iItem = 1;
pLVItem2->iGroupId = 1;
pLVItem2->pszText = _T("Richie");
pLVItem2->cchTextMax = 6;
ctrl.InsertItem(pLVItem2);
Cheers
AndyC
|
|
|
|
|
You've failed to state the problem. Are you getting compiler or linker errors? Is an assertion firing? Is an exception being thrown? I see very little error checking. Is this intentional, or done for the sake of brevity? Are any of the functions returning "error" status?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The problem is that the groups are not being displayed. When the lsit control gets displayed the two Items are present but like I said there are no groups.
The code included in my original post is a bit of proof of concept code, ie just to see the groups working.
I was convinced that none of the functions were returning error codes, so I have been back and checked just to be sure. None of the functions return an error code, however what doesn't seem right is the fact that bot calls to InsertGroup returns 0 it should return "index of the item that the group was added to". So I would expect the first call to return 0 but the second call I would expect to return 1.
Cheers
Andy
|
|
|
|
|
AndyCheetham wrote:
So I would expect the first call to return 0 but the second call I would expect to return 1.
As grouping is a new thing to VS.Net, I've no experience with it. In your code, you added two groups. You then added one item to each group. My guess is that the items in each group are independent of the other. In other words, if you added five items to the first group, they would be numbered 0-4. If you added five items to the second group, would they be numbered 0-4 or 5-9?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi David
Thanks for your input. Just thought I would let you know that I have solved the problem.
You need to include the following line in the rc file!
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "GLook.manifest"
where Glook.manifest id replaced with the file name for the manifest file for your application.
Unfortunately this is mentioned in the help file that I looked at when I first started looking into the problem. One day I will learn to read instructions more carefully.;)
Thanks for your help
Andy
|
|
|
|
|
What do you think about Linux? Do you use Linux for programming? Have you ever heard about Mono project? .NET strategy is working now under Linux. What do you think about that?
Thanks.
|
|
|
|
|
Well since I am bored, and have already hit my productivity quotient for the day, I'll bite.
I think that as a kernel Linux is fine. It has some nice features, scales well, is reasonably stable, and the new 2.6 version adds some nice performance improvments. So from a 10,000 foot view, it's OK, no better or worse than other kernels out there (well maybe a bit better, at least in terms of flexibility). However from a design standpoint, from a "lets try something new" standpoint, it's mind numbingly boring in a lot of ways. Linux carries on many unix traditions as if they were the be-all end-all of computer OS design, which is a shame, because IMHO, in 2004, many of the Unix design decisions are fairly lame. For example, security. Linux (and most Unices) security is *still* implemented as nothing more than a 32bit value that gets set. Win32 security mechanism (which is almost a direct copy of what's been used on VMS for the last 20 or so years) is infinitely more flexible, and far easier to admin in terms of understanding it, and making changes to the system.
Another example is the insistence on *everything* being a character stream (or practically everything). That and an incomprehensible naming pattern that makes understnading what devices you have connected to the OS extremely difficult. Don't beleive me? Look in /dev and tell me what all that is?
Linux the OS, i.e. all the userland stuff, like cp, ls, man, rm, cat, etc, is a dog, in my opinion. Most of the brain dead unix design decisions that were made in the 70's are *still* there in Linux! Keep in mind that the same group that whines, cries, and belittles MS for being un-innovative, has done *nothing* to bring linux forward using state of the art OS techniques and designs. From incomprehensible commands like cat, rm, ls (WTF is ls? please try explaining that to anyone not a programmer), awk, groff, sed, and on and on and one, ad nauseam.
And if you thought the commands were weird how about getting help? Want help? type man! What's "man" you ask? Why isn't it "help" (this is what VMS uses)?
Once you get used to terse 2-3 letter commands you have the joy of the linux file system to uncover. Want to find where something is executed from? Is it /usr/bin, /bin, /sbin, /usr/sbin, /usr/local/bin, etc etc. What's "bin"? What's "usr"? It's 2004, why can't we move forward and give human readable names to things. Keep in mind this is linux we are talking about - a freely available system that could be changed, but rarely is. Don't get me wrong, there are projects that attempt to changes bits and pieces of all of this, but none which do so in any well thought out cohesive manner. What's even worse is that even if it was done it's adoption would be glacial at best, since by and large the linux community appears to be every bit as conservative and locked into the past as the companies that the community makes fun of.
Another example of linux dippiness: shared libraries. People continually piss and moan about DLL Hell on Win32. And it's a completely valid criticism. Only its just as bad on linux/unix! You have stuff spread out all over the place, in directories whose location you're not even sure about, with symlinks to this, that and the other till you're blue in the face. All so you can load up the *right* version of your SO. When even the easiest option, i.e. putting the library right in the same directory as an exe, and the exe can't load it up! That's right, the ld program (the one responsible for loading the shared library), cannot find a SO that's in the same dir as the starting exe unless the lib is either added to the LD_LIBRARY_PATH, or hard coded into the exe's ld path during compilation/linkage. This is a carry over from unix, and never once has it been questioned AFAIK!
Do you use Linux for programming?
Well that depends on what kind of programming you're referring to. If you mean general system level stuff, then yeah I can imagine using it. But if you mean the nightmarish hack that is linux GUI development then hell no. Why do I say this? Good question!
Linux GUI development is a nightmare for several reasons. But the number one reason is the utter, and complete lack of any sort of suitable basic API to work with. Unlike Win32, MacOS Classic/OSX, AtheOS, NeXT, SkyOS, or BeOS (I threw in some hobby OS's just to show that even non-commercial attempts can get it right), the linux GUI has no standards, no base API to which a developer can write against. Instead there is simply a gaping vacuum that various toolkits try desparately to fill, causing endless, repititious re-invention of the wheel at almost every basic level of UI functionality, with varying degrees of success. For example, in most OS's the core API's you work with provide such basic features as:
-Clipboard support (both text and binary) for Copy/Paste
-Drag/Drop (or direct manipulation)
-Standard directory locations and API's for locating them
-basic graphics routines
-basic font handling and text drawing routines
-Menu bars, menus, and menu items
-tooltips
-a basic help system
-standard controls, like a text control, list control, dropdown, tree control, push button, radio button, check box, etc
When programming a GUI for linux NONE of this is "standard". Part of the treat of linux, one of the things that its' fans make such a big deal of, is the concept of "choice", that you can choose to use what ever you want. This is great from a system designer standpoint, or to someone putting together an OS distro. It's less than helpful to a developer who just wants to write their application. For example, in Win32 or OSX (or the other's I mentioned), one can request a font by passing in a font name (like "Times New Roman", or "Lucida"), and optionally a size, and maybe a few other parameters, and the system will guarantee to return you a font that matches as closely as possible to what you requested. This is accomplished because all these OSs build in a font mapper that knows how to do this.
Now attempting the same thing in linux is nowhere near as simple. First you must choose what toolkit you want to use. Why? Because unlike the other OSs linux has no native, core API's that handle this. B-b-but it has X, you say! X (or X Windows), in it's infinite wisdom, has no support for this either. It forces the end user to implement font mapping behaviour themselves! At best X can plop a rectangular window on a screen (but hey! it can do this remotely too! Woot!), and that's about it. Of course there are extensions to it (like XRENDER, XDAMAGE), but not everybody has them, and then you have to test for them, and ad nauseam, blah, blah, blah! Because X implementers and designers chose the path of least functionality (part of their mantra of "mechanism not policy"), the whole desktop has suffered. Great for university UI designers to play around with research ideas, but utterly lousy for developers who want to write real world applications with a standard UI.
Once you choose a toolkit you now have another problem. Each of the toolkits tends to be kind of mutally exclusive - you don't write an app in Qt and then add Gnome features, or a Gnome app and then add KDE features. It might be possible but it's ugly partially because your app is FORCED to load up both toolkits go achieve this, and then the user is of course forced to have both toolkits on their machine. Thus an application tends to be completely locked in to one toolkit, it's too expensive to change. And since linux offers no base library for any of the features listed above, every toolkit must implement these, which if we have the case above, means loading up dozens and dozens of smaller libraries, duplicating functionality all over the place. Keeping in mind that Gnome and KDE are both multi-million LOC projects.
Have you ever heard about Mono project? .NET strategy is working now under Linux. What do you think about that?
Yes I have heard of it. And I have said many times here on discussions about it that I think it's a walking lawsuit! If you had paying customers, on whose revenue and goodwill you dependended on for your livelihood, would you be willing to bet all of that on a Mono based solution, all on the chance that Microsoft will break with all prior behaviour and not pile-drive Mono into the ground should they ever start to catch on? Of course I'm not really a fan of .NET anyhow, much carbon copy of it, whose legality is kind of shaky at best.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
One of the best posts on Linux I have ever heard! It's a pity the rating system only goes up to 5 It deserves at least 10 times that...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Excellent post Jim. 10 from me as well. Having said that I have to report that I think you need to get VCF going on Linux, as painfull as that will be.
It seems that there is this unstoppable train moving towards Linux. Stuffed if I know what is going to happen to commercial software developers like me when that happens, suffice to say we'll need to change careers or retire, as it is hard to see anyone paying for Linux software.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Thanks!
Well the hardware's a tad more expensive, but, IMHO well worth it, so instead of linux, encourage everyone you know to consider OSX - at least they have a community that appreciates the full range of software, from free to commerical.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
I love it, use it as my day to day OS at home. Well I prefer freeBSD, but essentially everything applys, and I use both.
Everything is a file, and lamost always a file containing only charicters. This makes it simple. Once you can deal with files you can deal with anything. Oh once in a while you have to set some strange options (IP address means nothing on a file for instance).
The tools are powerful. Not easy to learn, but once you learn them easy to use and powerful. Tools like grep (searches for something in a file and can handle very complex searches) work because everything is a file of charicters.
Everything is logical and simple. Critical programs for a minimal system are in /bin, the rest of the system programs are in /usr/bin, and programs you install go in /usr/local/bin. 3 places to search and it is all there.
Remember, you cannot mistake easy to use with easy to learn. (Excpet when you are designing a kiosk where nobody uses it twice) Unix goes all the way: after a lot of training you can do some powerful things. Windows and the mac don't go nearly as far, and it makes powerful things hard to do.
vi deserves all the criticism it gets for being hard to learn and a pain to work with. I keep coming back to it though because it just works. Fast, and powerful.
|
|
|
|
|
/bin, /usr/bin, and /usr/local/bin, may be the layout on *your* system or distro, but it is by no means standard. There's /sbin, /usr/sbin, /usr/ucb (solaris looks for compilers there, beleive it or not), and I beleive other variations as well. The home directory, while frequently branched of off /home as a root, is not always done this way, for example solaris defaults to /export/home. Logical and simple would be to do what Apple does, or Win32 does - ONE directory (/Applications or /Program Files) for everything. The reason for having the multiple places to look was an easy hack solution to prevent people from running certain apps by just altering their $PATH. Of course if unix used real ACL's as a standard for file/process/etc permissions you wouldn't need any of that and you could just lock people down by group or user access, just like you can with Win32.
Remember, you cannot mistake easy to use with easy to learn.
This is just utter and complete bullshit, something all of us developers spout off about to justify writing sh*tty sloppy programs that are difficult to deal with. The fact of the matter is that Unix/Linux took dozens and dozens of sloppy, short sighted shortcuts in the way they implemented things, refusals to accept and enforce any sort of well thought out standards, and have stagnated as a result.
Note that I am not saying that Win32 or Mac are the end all be all of standards either. But, and it's an important but, they DO have a standard, and they do a pretty good job of enforcing it.
Windows and Macs, especially Macs, since they are BSD based under the hood now, and it's readily available, can be set up to do just as many difficult/powerful things as unix. And frequently where the "power" comes in is not from Unix per se, it's from the integrated high peformance hardware that it sits on.
What windows lacks is a really powerful native commandline line like unix that lets you easily script all sorts of crazy stuff. And it lacks some of the unix style comand line programs like sed and grep. However all of these have been ported over to windows and work just fine using cygwin, so it makes it a moot point to a certain degree.
If people *really* want to see fast, powerful, and well thought out, take a look at OpenVMS. It's been a complete eye-opener to see some of the stuff that it can do that unix, osx, and Win32 STILL don't do as well.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
I agree that unix is not the be all end all. I've never used VMS (or any mainframe OS), but I trust those who tell me there are advantages. However they are also able to see the disadvantages of those systems, one of which is losing some amount of power because not everything is a (normally text) file. Its a matter of trade offs. Unix ignored some things known about OS design when they designed it, but they also did a number of things right that windows ignored.
sbin is for system utilites that most users won't need, and often down have rights to call anyway. (If you need to be an admin to run some program why make is avaiable to the user?) I don't consider it fair to count that. And solaris does their own thing in most ways. There is a linux standards project that has standardised directory layouts, and most distributions follow it at least somewhat.
However all of this is just standard practice. I have a windows machine at work with a "c:\program files", and "d:\program files". I have seen linux distributions where all programs were in some form of /programs. With the standard unix layouts I can type "foo", and run a program that was just installed, while with windows I (or someone) has to adjust the path because programs are not installed in "program files" they are each installed in their own "program files\name" directory. Of course this has other advantages, so the only fair thing to say is it is different.
I still stand by the easy to use is not easy to learn comment. However you are not appling it as it was ment. Before you can decide where your program fits you need use cases to figure out who your users are. AT&T once made a complex hard to learn system because their operators were expected to use it for years, so saving a few tenths of a second here and there would not only making up the time to learn the system, but also save a lot of money. (this was back when AT&T was the monopoly) Most of us cannot go to that extreem because our users are not using only our app all day, but we do need to consider more than just learnability.
|
|
|
|
|
Hi,
This seems a newbie question. I wonder if we can set font for all Windows on screen with specify font? I tried to use Hook with message WM_PAINT and then do SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, TRUE).
However, some windows can change to new font, some cannot.
Please advise if there is any solution?
Thanks in advance
Khanh
|
|
|
|
|
Khanh Trinh wrote:
I wonder if we can set font for all Windows on screen...
Why would you want to do this? Unless an application needs a specific font, it should use the font that the user has established via control panel. Going against user settings is highly frowned upon. Further, no application should change the font used by another application.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
This is a special case, when the packaged software should use Windows default setting Fonts (include font and charset), however it does not. So in order to display correctly, I must do change font for that particular application.
Any idea in this case? I can change font for Buttons, Listbox, ComboBox, Textbox. But it seem the Editcontrol (Read-only), the Tab-label cannot be changed.
Thanks
|
|
|
|
|
Khanh Trinh wrote:
I can change font for Buttons, Listbox, ComboBox, Textbox. But it seem the Editcontrol
Strictly speaking, text box is a VB term, while VC++ uses the term edit control. Anyway, you've used both terms here, but apparently not interchangeably.
Khanh Trinh wrote:
But it seem the Editcontrol (Read-only), the Tab-label cannot be changed.
Are you talking about two different controls here? What is a "Tab-label?"
I'm not sure how you are changing the font of the other controls, but I use SetFont() when dealing with edit controls.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
you right about the terms. Actually, what I want is changing font of a combined application (another application) and I don't have that code. That's why I must set a Hook on WM_PAINT (not sure this message is correct or should capture another one), then do SendMessage with WM_SETFONT to set Font for that control.
Tab-label: I mean, the pages' caption of tab-control (sorry about incorrect terms)
So, with that I have dont, I can change font for most controls except somes indicated before.
|
|
|
|
|
I started an exe using createProcess and want to check on it:
while(1)
{
LPDWORD lpExitCode;
GetExitCodeProcess(ProcessInfo.hProcess, lpExitCode);
etc
}
I see in the debug that the hProcess isnt null (since my process started successfully). I was going to exit the process and see if I could detect it in my launching app. However, the code crashes at GetExitCodeProcess. I tried stepping into it, but it access violates immediately. What can I look into to see what is wrong?
As a workaround I am doing
while( ! (WaitForSingleObject(ProcessInfo.hProcess,1) == WAIT_OBJECT_0))
but I am curious as to why the first call crashes.
thanks,
sb
|
|
|
|
|
Should be:
DWORD dwExitCode;
GetExitCodeProcess(ProcessInfo.hProcess, &dwExitCode);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
ns wrote:
As a workaround I am doing
That's not a workaround... That's the way it should be done David's solution will fix the first call.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
hello,
Does anybody know how to fix the error that I sometimes get with my application: the error is the nb 995 with the GetLasterror() function, and it says in the help:"when a I/0 operation is interrupted". My application is almost like a ping on a serial link of a PC to a special device: it writes a byte and then read the serial link to see if an answer is coming. It waits around 10 ms, and if nothing is arrived, it tries again. But sometimes, the fonction that reads the file that stores incoming data returns with this error 995. It can not happen a hundred times, but the one time it happens, it blocks everything(I mean my application cannot write/read on the serial link anymore), even if I exit from the application and come back it will happen again until I reboot my PC, and then everything is back to normal.
Please, HEEEELPPPPP!!!!
sojijolan
|
|
|
|
|