|
Immunity18 wrote: ...which is the way to do that ?
STL has plenty of options, like istream /ostream and ifstream /ofstream . I'm an STL novice so I'm sure it has more.
MFC offers the CFile and CStdioFile classes.
With C you can use FILE* .
The Windows SDK has CreateFile() , ReadFile() , etc.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I intend to integrate the functionality of two dlls into one by means of merging the code. I'm adopting the following steps.
1) Create a master framework for the merged entity say dll A.
2) Include all the files that are distinct for the two dlls(B & C) into the project created for dll A.
3) For all the files that are same in dll B and C, include a single file into the merged entity and into that file put all the functions that are distinct in the file under B and C.
I think this should suffice. Please correct if there is something to be done
The problem comes for functions that are same in the common file.
Say in dll B We have a function like
class B : function()
{
}
Say in dll C We have a function like
class C : function()
{
}
Here the two different functions need to be merged into a single function under a class name.
Now my question is how does the merged entity break into two workflows similar to the functional behavior in the previous separate dlls? What kind of conditional can be put for identifying the different behaviors?
Thanks
|
|
|
|
|
hi guys,
I come with a small question.
I want to add, as a resource, a small midi file to my application and play it continuosly during program execution. So that when the application is open the sound is played...and it stops when the app is closed.
Time ago i founded a code snippet which uses directx8 but i don't why it worked only on my pc...but not on other people pc.
Thanx in advance
|
|
|
|
|
Hi!
I'm pretty new to C++, I read some big books about it and got pretty much into the basic thinking in C++. Unfortunately I did not learn how to simply write a tool with a basic windows XP interface containing one button, which executes an action when I hit it.
To be more specific, I want to code a tool for XP that got one button and when I hit this button it will send a telnet.
Can anyone help me plz? Cause I just don't know the very simple basics for writing a very simple tool with GUI.
Thanks a lot!
Phong
|
|
|
|
|
Use AppWizard to create a dialog-based application. Add a button to the dialog template. Handle the BN_CLICKED message for that button.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Phong.T wrote: it will send a telnet.
Phong.T wrote: I just don't know the very simple basics for writing a very simple tool
Not sure "telnet" would qualify as "simple"
led mike
|
|
|
|
|
Hello,
In my application when the left button is pressed on the scroll bar the scroll bar moves but the the screen display remains the same it doesn't move with the scroll bar.
What do I need to do?
What should ne written in the OnDraw() method?
Prithaa
|
|
|
|
|
if MDI or SDI app then use CScrollView it will handle
every thing for you.
If you yourself wana do do you yourself have to handle
CWnd::OnHScroll
in that function check how much to scroll
and then do the drawing according to that.
will help
|
|
|
|
|
A list box is configured with both horizontal and vertical scroll. A string is inserted that is greater in width than the display area, but the horizontal scroll won't allow scrolling to the end of the string. What additional functions need to be called to enable the horizontal scrolling? Thanks.
|
|
|
|
|
jon_fallon wrote: What additional functions need to be called to enable the horizontal scrolling?
How about setting the control's horizontal extent?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Using the SetColumnWidth? I tried this, but it didn't change anything.
CListBox *lbptr=(CListBox *) GetDlgItem (IDC_LIST_TAB1_IDW );
CString s;
POSITION pos = fileDlg.GetStartPosition();
while (pos)
{
s = fileDlg.GetNextPathName(pos);
lbptr->AddString(s);
}
lbptr->SetColumnWidth(1000);
lbptr->UpdateData();
|
|
|
|
|
jon_fallon wrote: Using the SetColumnWidth?
No. Use SetHorizontalExtent() .
jon_fallon wrote: lbptr->UpdateData();
Totally unnecessary.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hey.. i managed to create a button on the SHBrowseForFolder form. When clicked, I want this button to set the selected folder to My Pictures. This is the event that i'm triggering whenever I press the button. However, this is not working. I read that the message BFFM_SETSELECTION could only be used at BFFM_INITIALIZED at the BrowseCallbackProc. If this is true, how can I set the selected tree view to select My Pictures folder whenever I press this button?
LRESULT APIENTRY DefaultFolderSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
if (uMsg == WM_LBUTTONUP)
{
TCHAR buffer[_MAX_PATH];
if (CFileHelper::GetMyPicturesFolder(buffer))
{
::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer );
}
}
return CallWindowProc(CBProc, hwnd, uMsg,
wParam, lParam);
}
|
|
|
|
|
skullfire wrote: I read that the message BFFM_SETSELECTION could only be used at BFFM_INITIALIZED at the BrowseCallbackProc.
BFFM_INITIALIZED is sent by the dialog to your callback routine.
skullfire wrote: ::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer );
This is correct. Is hwnd the correct window handle? Does buffer contain a valid path?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes to all. I know that about the BFFM_INITIALIZED. I even tested to save the hwnd into a global variable where I made the regular call at the BFFM_INITIALIZED(the one that works) (inside the BrowseCallbackProc) and used this global variable to send a message on button click.
|
|
|
|
|
I'm passing a pointer to an object into a function where I would like to validate it. I remember seeing a simple typecast used to do this, but I cannot remember exactly how it was done. My attempt returns the same pointer even though it is totaly bogus.
CImage *tmp = dynamic_cast<CImage*>(cImage);
if ( tmp )
{
m_ImagePtr = tmp;
}
|
|
|
|
|
So what exactly is the problem? What is cImage ?
waldermort wrote: I'm passing a pointer to an object into a function...
What function?
waldermort wrote: My attempt returns the same pointer...
What exactly does this mean?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
CImage is a class. Perhaps if I show the full function.
bool CImage::SwapImage( CImage *cImage )
{
CImage *tmp = dynamic_cast<CImage*>(cImage);
if ( tmp )
{
m_ImagePtr = tmp;
return true;
}
return false;
}
I'm testing the call like this
CImage::SwapImage((CImage*)0xffffffff);
Which results in the value of tmp being 0xFFFFFFFF, whereas I want it to bu NULL.
I should also point out that I need to test the pointer using a similar method in the case that the provided pointer is no longer available. ie.
void CImage::Draw( HDC hdc )
{
CImage *tmp = dynamic_cast<CImage*>(m_ImagePtr);
if ( tmp )
return m_ImagePtr->Draw(hdc);
|
|
|
|
|
waldermort wrote: Which results in the value of tmp being 0xFFFFFFFF, whereas I want it to bu NULL.
As it should. Your if-statement is checking against a non-zero value, so your pointer will be set to 0xffffffff and the function will return true. If you want to check it against valid values, you need to specify what those are in the if-statement (or rather, what values are invalid).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I understand that, but all I need to do is assert that the cImage pointer is pointing to a valid CImage instance (ie. it has not been destroyed). I was hoping that the dynamic_cast would return NULL if the pointer is not valid, but this doesn't seem to be the case.
|
|
|
|
|
If CImage is a class of your own making, then you have control over whether it contains valid data or not. Much like COleDateTime has a GetStatus() method, you can employ the same thing.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The question is simple, regardless of the type of pointer, how can you test it is still pointing to a valid location and not since gone out of scope?
I am passing a pointer to a class. The class will store the pointer and later call methods from the pointer. If I pass in a pointer, then delete the memory it's pointing to, then try to call those methods, the program will crash, even though the stored pointer is holding what it thinks is a valid address. There must be a simple way to test a pointer.
|
|
|
|
|
waldermort wrote: The whole point of my question is to find out how to correctly validate that a pointer is poining to a certain type...
Then use IsKindOf() .
waldermort wrote: ...the docs say that if dynamic_cast fails it returns NULL...
Right, but it has no way of knowing if your CImage object is valid or not. A pointer value of 0xffffffff is valid.
waldermort wrote: If I pass in a pointer, then delete the memory it's pointing to...
After deleting, you must also assign NULL to the pointer. Anything short of this is just asking for trouble.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
IsKindOf() is MFC only, which unfortunatly I am not using. I can see why dynamic_cast is failing, simply because it should be used to convert one type to another, not for validation like I am trying to do. I usually always assign NULL to a pointer both on creation and deletion, but in this case it's not possible. I must test the pointer somehow before trying to use it.
|
|
|
|