|
Interestingly, David Kruglinski, George Shepherd and Scott Wingo, on page 264 of their book, "Programming Microsoft Visual C++: Fifth Edition" shows something similar to what the other author whom I was talking about, had done.
CBitmapButton m_editCopy;
CBitmapButton m_editCut;
CBitmapButton m_editPaste;
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
Verify(m_editCopy.AutoLoad(IDC_BUTTON1, this));
Verify(m_editCut.AutoLoad(IDC_BUTTON2, this));
Verify(m_editPaste.AutoLoad(IDC_BUTTON3, this));
return TRUE;
}
And they showed an illustration of a dialog window with the three Bitmap buttons. It obviously had to work for them also.
It got to be something else that they are doing, because the technique is not working for me.
William
|
|
|
|
|
When I double click on a file whose extension is handled by my MDI app, it starts to run the app but doesn't show the MainFrame properly (the floating dialogbar appears, but no main window or anything).
I get an error saying "Cannot find the file ... Make sure the path and filename are correct and that all required libraries are available."
I think these might be two separate problems, because when I click OK on the error message the half-opened application remains.
The same thing happens when another instance of the app is running. I'm not trying to do anything tricky here, like open the file in the same instance, which just seems too difficult. I've found similar postings on this forum but nothing that helps here.
thanks,
Jake
|
|
|
|
|
Did u serialize ur data?
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Yes, if I run the app normally and load in the file, everything works fine. Drag and drop also works fine. The only problems occur when double-clicking on files.
Jake
|
|
|
|
|
Does ur application name or path contains space characters?
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hey guys
I have been desperately trying to export data (just varibles) from an executable and load them into a DLL but i can't get it to work so far i have tried extern and __declspec(dllexport) and dllimport. But i have had no luck any ideas on how i do this.
Peter
|
|
|
|
|
You can't do that. You can only export objects from a DLL to an executable or another dll.
|
|
|
|
|
Yeah but i really really need to do it
is there no way to work around it
|
|
|
|
|
Create the exported object in the dll, then in the application change its value. There is NO other way to do it. The reason should be obvious -- if the application were allowed to export and object, then the application would always have to be running whenever the dll is running. Lets say you have A.exe that export and object which X.dll uses. B.exe also uses X.dll but has no need for the object. When B.exe runs, X.dll is brought into memory, and because the dll references the object that was exported by A.exe, A.exe must also be executed.
One of the purposes of a dll is to share its data and functions among many different applications. It would be terribly inefficnent to do it the other way around.
|
|
|
|
|
Trying not to make any assumptions, I have been making my code so that strings retrieved from edit controls, the registry, etc dynamically allocate the space needed.
In my code I have been doing things such as this all over the place:
<br />
_TCHAR* pszString = NULL;<br />
int iLen = 0;<br />
<br />
iLen = SendDlgItemMessage(hWnd, IDC_EDITCNTRL, EM_LINELENGTH, (WPARAM)0, (LPARAM)0);
iLen++;
pszString = new _TCHAR[iLen];
ZeroMemory(pszString, iLen);
*(WORD *)pszString = iLen;
SendDlgItemMessage(hWnd, IDC_EDITCNTRL, EM_GETLINE, (WPARAM 0, (LPARAM)pszString);
<br />
<br />
delete []pszString;
<br />
This is of course just example code, but is the most optimized way to go about allocating the space for strings dynamically? I'm just curious how most people go about this in Windows.
Thanks!
. djrisc .
|
|
|
|
|
I've never seen anythging like this. Its much more sophisicated than I'm used to. Most code I've seen (and written for that matter) just allocates a large buffer and uses GetDlgItemText, letting the extra space (if any)just lie there.
I don't know if it is the most optimized, but it looks like it is considerably more efficient than the norm!
|
|
|
|
|
That is right - call with WPARAM and LPARAM of 0 to get the length, then add 1 for a null terminator.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
If you're doing that often I'd simpify the code to something like
CBuffer buffer(GetEditCtrlSize(hWnd, IDC_EDITCNTRL));
GetEditCtrlText(hWnd, IDC_EDITCNTRL, buffer);
where CBuffer is a class that does your new, zero, delete etc. Even better would be to use a std::vector as a buffer if you can.
Todd Smith
|
|
|
|
|
... shows HOWTO: Convert a UNIX time_t to a Win32 FILETIME or SYSTEMTIME.
... However I need an easy way to do convert FILETIME to time_t without MFC-Support.
Any help welcome
Rainer
|
|
|
|
|
something like this:
FileTimeToSystemTime(&ft, &st);
struct tm now;
...set now's members based on st's members
time_t timeNow = mktime(&now);
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
|
by using peekMessgae or GetMessage how to moniter a button that it is clicked ?
can any write a little code ?
r00d0034@yahoo.com
|
|
|
|
|
The parent of the button receives a WM_COMMAND message to notify it of events including button clicks. If the high word of wParam is BN_CLICKED and the low word of wParam is the ID of the button, the button was clicked.
Next time, to make it easier on us, go into greater detail if you can.
Peter O.
|
|
|
|
|
Ummmm.... Maybe he doesn't speak English as his native language. CP is a world wide site with users from every point on the globe. If you can't handle broken English, then you will find yourself very frustrated here.
Tim Smith
"Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution."
Hoare - 1980 ACM Turing Award Lecture
|
|
|
|
|
How to retrieve attachments from a POP3 server?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I have a List control class that contains a couple of image lists to give large and small icons against each entry.
The list control is used in a number of places so I don't want to have multiple image lists in memory for each list control. At present I am storing the image list in my document class, then using this each time. I would like to improve this as obviously the document should have nothing to do with the view.
Any suggestions? I am thinking about maybe have a constant Image list in my control class, but then this would be initialised more than once. What about a singleton?
|
|
|
|
|
It sounds like it would more properly be a global. You are making a global usage of it.
|
|
|
|
|
But I always thought globals were evil and the spawn of the devil!
Mind you, could I have a 'global' class that contains all the bitmaps and images used by my application?
|
|
|
|
|
Only if you hang mistletoe over it and twirl a dead cat three times at midnight.
Yes a global instance of a class that stores that stuff is just fine. Globals are a bad idea, only when misused. That is, when they are used simply to avoid keeping track of the scope of variables.
Your application is exactly what globals are invented for.
|
|
|
|
|
Ahh, ok, I have not created a 'resource holder' class that holds objects for all my resource. I then call a function on this class when I want a handle to whatever bitmap. It now seems to work quite well.
One thing I did notice though it I can't load the resources until my Application class has contructed, so I have to put a small check in their to load the resource the first time I access one. I suppose I could call a 'create' type function from the Application class, but this way I benefit from delaying the loading of resources until I need them.
|
|
|
|