|
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.
|
|
|
|
|
waldermort wrote: IsKindOf() is MFC only, which unfortunatly I am not using.
What about typeid() ?
waldermort wrote: 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.
Can you modify the CImage class?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
type_info and typeof both return char pointer to the type name associated with the pointer, they do not perform any pointer validation. Unfortunatly it looks like I am going to have to rethink this. Yes, I can modify the CImage class.
CImage is a base class which holds and draws a series of DIB sections. My basic idea is to give the class the ability to draw the image contained within another instance of the class (a little like swapping the this pointer). Since the drawing functions will be called often, I would prefer to store the pointer, that way I only need to change the image once rather than passing a pointer for each bitblt call.
|
|
|
|
|
The pointer is valid, the object it is pointing to is not. What you can do is add a static method to cImage to check the status of a pointer you pass to it to see if it is a valid object of that type.
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
|
|
|
|
|
waldermort wrote: Which results in the value of tmp being 0xFFFFFFFF...
Of course it does. Why would it be anything else? It should retain that value until it is assigned something different.
waldermort wrote: ...whereas I want it to bu NULL.
Then you can't call SwapImage() with a non-NULL value.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Of course it does. Why would it be anything else? It should retain that value until it is assigned something different.
The whole point of my question is to find out how to correctly validate that a pointer is poining to a certain type, NOT to find out how large your ego is! If I knew it would give me those results I would not have used it in the first place now would I? I am testing for NULL because the docs say that if dynamic_cast fails it returns NULL and throws an error, it seems logical to me that if the return value is not NULL then the provided pointer is valid.
|
|
|
|