|
I am trying to organise the approach our organisation will take to using multiple resource scripts/headers in a new product. MSDN outlines the unpleasant way that this is to be accomplished in VC++, but I was hoping someone could tell me of an app/plugin/method that could relieve some of the burden (the 'manual' bits, particularly having to put the _APS_NEXT_ bits in the headers)...
|
|
|
|
|
Sadly, Visual C++ only likes on .RC file. If you are willing to manually manage other RC files, you can do it, but you won't get the nice VS IDE interface. This is one of the largest drawbacks to VC. I wish they used a seperate RC for each dialog, and a seperate RC for strings, etc..
There are no easy solutions here, sadly.
|
|
|
|
|
Thanks, Erik
TN035 in MSDN outlines how you actually can uses multiple .rc files in one application (one for strings, each dialog ...), and still use the IDE to insert resources into them, edit them etc. (without the joys of classwizard, though). The problem is that you must manually assign a range of values (the _APS_NEXT_XXX statements) to each file.
I wonder if VS.NET will fix these problems! (makes you wonder how VS can call itself an 'enterprise' solution in this case ... makes life tedious for 3 of us, can't imagine trying with a dev team of 100!!!)
|
|
|
|
|
been messing around with the methods in TN035 - the IDE choked, and even kept deleting from the hard disk one of my header files !!! -- can I ask if anyone has gotten this to work?
|
|
|
|
|
As you have found out, those tech notes were written YEARS ago. Literally almost 10 years ago. While they still theoretically apply, in practice it's not quite as simple as they claim.
Further, there are many problems with multiple .RC files, for instance if you drag a resource from one RC to another in the IDE, it copies the ID it had when it was created, you'll have to manually set its ID and adjust the high water marks (the _APS_NEXT stuff) to compensate.
What i've found to work (though not something i'd call optimum) is to issue a rule that nobody can hold the .RC and resource.h files checked out for more than a set amount of time, and they should always check it back in as soon as possible. Going home at night with it checked out is a beer/doghnut/coffee for the team/lunch buying offense.
Of course, that's not enough, you still have to go through every so often and renumber things because someone, somewhere will manage to mangle something.
|
|
|
|
|
Firstly is there a non MFC equivalent of CTime and CTimeSpan that I can use in ATL?
Secondly is it possible to convert a CTime object to a string then later convert that string back into a CTime object?
Thanks
|
|
|
|
|
CTime::Format() will convert a CTime object into a CString, going to the other way is more difficult. You must parse the date/time string yourself and pass the values to a CTime constructor.
|
|
|
|
|
hello,
i have to find the largest number out of a list contained in "testfile", all i could get to show was the largest of the last two numbers read, if someone could give me hint what is wrong i would be thankful
Shawn
int main ()
{
int num, nextnum, largest;
ifstream infile;
infile.open ("testfile");
infile >> num >> nextnum;
largest = 0;
while (!infile.fail())
{
if (num > nextnum)
{
largest = num;
}
else
largest = nextnum;
infile >> num >> nextnum;
}
cout << "Largest: " << largest << endl;
infile.close ();
return 0;
}
|
|
|
|
|
I did. (HINT: take a close look at how you are extracting the data)
|
|
|
|
|
You are only ever going to be working with the last two numbers read, as you are not testing to see if num or nextnum are larger than largest before over writing the value. If the file contains only one column of numbers you only need to read into num (infile >> num) and also have the one if statement testing against largest in the while loop.
Try the following.
int main ()
{
int num, nextnum, largest;
ifstream infile;
infile.open ("testfile");
infile >> num >> nextnum;
largest = 0;
while (!infile.fail())
{
if (num > largest)
{
largest = num;
}
if (nextnum > largest)
{
largest = nextnum;
}
infile >> num >> nextnum;
}
cout << "Largest: " << largest << endl;
infile.close ();
return 0;
}
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Hi I am trying to call a DLL (for testing I use the SetWindowTextA function from User32.dll)
Everything seems correct to me...and the program compiles and links fine, except that on executing it, it given an illegal operation. I have checked that SetWindowTextA is in User32.dll, so I guess it should work?
Here is the code:
#include<windows.h>
#define TAILLE_MAX 40
void main()
{
char *szFuncName = "SetWindowTextA";
char *szDllName = "User32.dll";
HINSTANCE hLibrary;
HWND hwnd;
char szOldWndTitle[TAILLE_MAX];
char *szNewWndTitle = "Changed Title";
BOOL RetVal;
GetConsoleTitle(szOldWndTitle, TAILLE_MAX);
hwnd = FindWindow(NULL, szOldWndTitle);
__asm
{
push szDllName
call LoadLibrary
mov hLibrary, eax
push szFuncName
push hLibrary
call GetProcAddress ;eax recieves function pointer
push szNewWndTitle
push hwnd
call eax
mov RetVal, eax
push hLibrary
call FreeLibrary
}
}
Any ideas what is wrong?
Thanks in advance
|
|
|
|
|
Hi,
how can I load, view, modify and save
domain users's ACL registrered into HKCR\AppID\object's GUID\AccessPermission subkey of registry?
I've already used RegQueryValueEx Api in my C++ program but i don't know to interpret ACL in it.
Help me, thanks!
|
|
|
|
|
Can I use CTime in a Win32 application?
SomW
|
|
|
|
|
I never tried but I think Yes you can,but you must include <winafx.h> header.
|
|
|
|
|
Short answer: no
long answer: It can be done, but it's very tricky to rip a single class out of MFC; and adding full MFC support to the project is probably not what you want either.
|
|
|
|
|
Hi,
My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll.
My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack.
But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress?
Any Answers/Suggestions?
Thanks in advance,
Mvworld
|
|
|
|
|
Hello, the codegurus around the world.;)
In fact, I don't know what your assembler code does?
But, if the assembler code can call Java class, you can use JINI to call DLL
file which you created.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi,
I have been trying to use run time linking with Dll files. I am new to Windows programming, so I am confused what is causing the error in my program.
I am trying to use run time linking to change the Window Title of a Console widow.
Here is the code:
#include
typedef BOOL (WINAPI *LPFNDLLFUNC) (HINSTANCE hInstance, char *dwText);
void main()
{
HINSTANCE hLibrary;
LPFNDLLFUNC lpfnDllFunc;
BOOL RetVal;
char dwString[] = "Changed Text";
HWND hwnd;
char pszWindowTitle[40];
GetConsoleTitle(pszWindowTitle, 40);
hwnd = FindWindow(NULL, pszWindowTitle);
hLibrary = LoadLibrary("USER32.DLL");
lpfnDllFunc = (LPFNDLLFUNC) GetProcAddress(hLibrary, "SetWindowText");
RetVal = lpfnDllFunc(hLibrary, dwString);
}
It compiles and links fine, but it performs an illegal operation on running it.
On debugging I get the following message:
Unhandeled exception in Testing.exe:OxC0000005:Access Violation
Any ideas?
|
|
|
|
|
Hello, the codegurus around the world;)
First of all, I don't know the exact answer, but
have you ever written C or C++ code?
>> I am new to Windows programming.
So, you know C?
I mean, why don't you use if-else statement to check if the function returns the right value.
1) Check if FindWindow works fine?
2) If 1) works, go to 3)
3) Check if LoadLibrary works fine?
4) If 3) works, go to 4)
5) Check if GetProcAddress works fine?
6) If 5) works, go t 7)
7) Try to use SetWidnowText(...)
I think that any programmer needs this kind of approaches even though we use Java or C++.
Anyway, I think that SetWindowText's first arguement passes HWND, not HINSTANCE?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Have you traced through the code yet? You'll see that lpfnDllFunc is NULL. That's because there is no function "SetWindowText". There are "SetWindowTextA" and "SetWindowTextW" for ANSI and Unicode, respectively. Your code is using plain chars, so use the ANSI version.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi mate,
Yeah I took note of it, just careless mistake I suppose.
Thanks a ton though
|
|
|
|
|
FindWindow(A/W) and SetWindowText(A/W) both lives in user32.dll. If you are using FindWindow using static link, why do you need runtime linking for SetWindowText?
|
|
|
|
|
This problem is a part of a larger study problem I have for my college project.
I am basically experimenting with all the calling conventions etc...and this will finally be used in code for XEmacs, which is a unix originated text editor.
|
|
|
|
|
How can I implement an application to send data over a network (by using a custom-made OLEDB provider) the same way commercial DBMS communicate with data consumers?
Ernesto Moscoso Cam
|
|
|
|
|
Hi All,
I have a BSTR string variable via ADO Recordset Getstring method. In the BSTR string has null
character('\0'). How can I get rid them of in a common way(Of course I can loop from start of
BSTR, but I want a directly way).
Thank you.
chenzhu
|
|
|
|