|
tom groezer wrote: Is there any association with the registry key NtfsDisable8dot3
Yes - the first Google hit for 'NtfsDisable8dot3'[^] could have told you that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Is there any other reason for such behavior
|
|
|
|
|
For starters:
- The filesystem on which the file resides does not support short filenames (so, NTFS with the registry key we talked about, HFS+, extfs via a network connection)
- The file doesn't exist - it has to for
GetShortPathName to work
Did you check the extended error information (with GetLastError ) to see what error was signalled?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have written a small C++ program using Visual Studio 2008. I use the resource editor to create some menus and then look for the appropriate events in the callback routine to perform whatever action is needed when a certain menu item is selected (part of the callback routine is below):
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
int wmId;
switch (message) {
case WM_COMMAND:
wmId = LOWORD(wParam);
// Parse the menu selections:
switch (wmId) {
case ID_TOOLS_INITIALIZECOMPORT:
SetupStuff();
initialized = true;
break;
case ID_TOOLS_CALIBRATE:
reCalibrate();
break;
...
I'd like to know how to modify the properties of the menu items from the code (for example changing the text or setting a check-mark etc) but since I used the resource editor to create the menus I don't know how to get their handles or how to access their properties - all I know for each menu item is its ID.
I'm sure I'm just being stupid but any advice would be greatly appreciated.
Mats
|
|
|
|
|
If it's the same as the sample I just created, you specify the menu in the window class:
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_XX));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_XX);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
To get the menu for a window of this class, use GetMenu[^] using the window handle.
[edit]Here's a sample commnd handler (insert in a switch statement like the one you have in your post) that inverts the checked state for a menu item (ID_FILE_TESTITEM) when the menu item is selected. This does assume that the File menu is the first sub-menu on the menu bar.
case ID_FILE_TESTITEM:
{
HMENU menu = GetMenu(hWnd);
menu = GetSubMenu(menu, 0);
const bool checked = (GetMenuState(menu, ID_FILE_TESTITEM, MF_BYCOMMAND)&MF_CHECKED)==MF_CHECKED;
CheckMenuItem(menu, ID_FILE_TESTITEM, MF_BYCOMMAND | (checked?MF_UNCHECKED:MF_CHECKED));
}
[/edit]
PS - any reason you're using raw C/C++ rather than a framework (WTL or MFC)? They do make it easier to do all this, honest
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Sunday, March 1, 2009 4:25 PM
|
|
|
|
|
Thanks!! That worked and was just what I needed!
As to why I'm doing it this way - I basically don't know any better. I am rather new to windows programming (lets just say that I learned FORTRAN using punch cards). The application I am writing is controlling some hardware so until today I was more focused on just getting the code to talk to serial ports and didn't want to try learning anything else at the same time. As long as we are on that topic, though, can you recommend a good book (or other resource) for someone starting out with MFC or WTL - something with decent examples that an old fart used to programming in vanilla C can understand
|
|
|
|
|
Mats Selen wrote: As to why I'm doing it this way - I basically don't know any better. I am rather new to windows programming
Fair enough
Mats Selen wrote: can you recommend a good book (or other resource) for someone starting out with MFC or WTL - something with decent examples that an old fart used to programming in vanilla C can understand
For WTL - Michael Dunn's article series on this site[^] is good.
For MFC - mmmmm, not sure. I started MFC programming over 10 years ago, when there were still MFC books around. I think it was an earlier version of this book[^]. If you have a Safari[^] subscription, that's on there.
Apart from that, best I can suggest is Google and possibly this[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Thanks - you guys make this a great forum!
|
|
|
|
|
Hi
I want to use vector to save following struct. It it possible?
template <class t="">
struct Cell
{
T Val;
};
vector <<cell>> vname ?????
What is the best solution for it?
Thanks,
modified on Sunday, March 1, 2009 1:49 PM
|
|
|
|
|
For example:
template <typename T>
struct Cell
{
T Val;
};
#define CELL_TEMPLATE(type) Cell<type>
std::vector<CELL_TEMPLATE(int)> my_cell_vector;
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thank you very much for your reply. I want to use one vector to save different data type of data. How can I do it?
Best,
|
|
|
|
|
What exactly do you mean by "save"?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
like following:
Cell<int> typeint;
typeint.Val = 1;
recVec.push_back (typeint);
Cell<float> typefloat;
typefloat.Val = (float) 1.111;
recVec.push_back (typefloat);
|
|
|
|
|
Well, if the structure isn't too complex, you could simply use a union and some way to signal what type your struct is actually holding. Something like:
#define STRUCT_TYPE_FLOAT 1
#define STRUCT_TYPE_DOUBLE 2
#define STRUCT_TYPE_INT 3
...
struct Cell
{
public:
short typeFlag;
union {
float valFloat;
double valDouble;
int valInt;
...
};
};
...
std::vector<Cell> my_vector;
Cell cell_double;
cell_double.valDouble = 1.23;
cell_double.typeFlag = STRUCT_TYPE_DOUBLE;
my_vector.push_back(cell_double);
Cell cell_int;
cell_int.valInt = 123;
cell_int.typeFlag = STRUCT_TYPE_INT;
my_vector.push_back(cell_int);
...
If it's a bit more complex than that then you should rather use pointers, something like this:
class CellBase
{
virtual ~CellBase()
};
template<typename TType>
class Cell: public CellBase
{
...
};
std::vector<cellbase> my_vector;
my_vector.push_back(new Cell<int>(123));
These are far from complete implementations of anything, just "skeletons"...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Hmm, this is strange, i got a new notification of you posting something here, i click the link in the email, it brings me to this page but your message does not appear. I already got one of these once, maybe it is some caching problem, or something i don't yet know about the forums. Anyways, the email itself contains your post so here's an answer to that: in your CCellBase, make the destructor public.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I found the problem. Your solution is perfect.
Best,
|
|
|
|
|
One alternative to Code-o-mat's is to use a 'proper' type-safe variant class like Boost.Variant[^].
typedef boost::variant<int, float> Cell;
std::vector<Cell> cells;
cells.push_back(10);
cells.push_back(12.0);
for (int i=0;i<cells.size();++i)
{
if ( int* pi = boost::get<int>( cells[i] ) )
std::cout << "cells[" << i << "] = " << *pi << std::endl;
else if ( float* pf = boost::get<float>( cells[i] ) )
std::cout << "cells[" << i << "] = " << *pf << std::endl;
}
One design feature of the Boost.Variant is that you need to know what types you want to store when you build the program. Alternatively, you could use a Boost.Any[^], which allows you to store values of any type within it without pre-declaring them.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Can a ellipsis (Variadic) function i.e Func(...) be exported from a DLL.
The function takes variable number of arguments. Can this be exported through a dll?
|
|
|
|
|
Don't see why not - the C run time DLL manages it for printf, sprintf etc which are variadic.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
thanks for the reply, since standard functions are exported so the user defined must also be exported.
|
|
|
|
|
well i want image of any extension to be converted into binary and save it into some file. then read it back to generate image can any one help me plz
|
|
|
|
|
Well, ANY extension (i assume you mean format by extension, since extension is just some characters after the name of the image, which basicly means nothing, i can rename my Whatever.bmp to Whatever.jpg, that won't actually make it a JPEG image...) is a bit broad, but you can use CxImage[^] to load many kinds of formats, then you can create a DIB section using CreateDIBSection[^] and then blit the image onto it. Since CreateDIBSection gives you a pointer at the pixel data, you can do with it whatever you like, like save it as it is. Doing this the other way should be quite straightforward too. Hope that helps.
p.s: Could be that CxImage itself gives you a way to access the "raw" pixel data (or even save it as raw format), am not sure about that, but you can find that out yourself.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
They are already binary. May be you want to encrypt/decrypt them.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|