|
Hi,
I need to know when an item is clicked in a ListView Control. And Which Items It is.
I used the class wizzard to respond to the NM_Click Message. This gives me the following function header definition.
void CResultsDlg::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
How can i find out which item is clicked?
Cheers
Rich
|
|
|
|
|
Try looking here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/ListView/Notifications/NM_CLICK_LISTVIEW.asp
The key is to cast the pNMHDR to a NMITEMACTIVATE pointer and access the iItem and iSubItem members.
Lee Nowotny
|
|
|
|
|
Does anyone knows how can be subclassed SpinButton of the TabCtrl ?
I want to change it with my own.
|
|
|
|
|
Hi,
What I wanna achieve is this:
I want to be able to split a frame like this with different wiews:
---------------
| |
| View 1 |
| |
---------------
| | |
|View 2|View 3|
| | |
---------------
Then by clicking a button or through a menu command I would like to change the frame view becausu I don't like the view layout. So I would like to get this view by the button click:
---------------
| | |
|View 1| |
| | |
|------|View 2|
| | |
|View 3| |
| | |
---------------
Does anyone know how to do this? (code sample?) Your help would be GREATLY appreciated,
/Tommy
|
|
|
|
|
The MSDN for the WinSock bind API call states:
For TCP/IP, if the port is specified as zero, the service
provider assigns a unique port to the application with a
value between 1024 and 5000.
..
Binding to a specific port number other than port 0 is
discouraged for client applications, since there is a
danger of conflicting with another socket already using
that port number.
Unfortunately it does not say when the allocated port number is released. When using this technique I always get the last port number increased by one. Does that mean that this method can only succeed up to 3976 times and will then fail? Or will the port number start again with 1024 after 5000 has been reached?
In summary: Does anybody know more about this feature or have some references?
Oliver
|
|
|
|
|
1) I wish to generate an error when i write:
unsigned int i;
cin >> i;
//the user inputs '2.5' ( a double, incompetible type)
or '-1' ( a signed int, incompetible type)
I used:
if ( !cin || cin.fail( ) )
{
cin.ignore(256, '\n');
cin.clear( );
cin.sync( );
//cout >> someError;
}
It never got inside this block. WHY?
2) /* STL string */ string s;
cin >> s; // The user inputs: "I hate C++ projects"
cout << s; // Output: "i"
Same Q: WHY?
and how do i ( without using another buffer )?
|
|
|
|
|
1. C++ will implicitly convert your number to the appropriate type in the stream operation. I would initially pull the number in as a string, parse it for correctness and then store it the actual variable.
RegEx can help you with this: http://www.boost.org/libs/regex/index.htm or you could write your own state machine to parse it. (But I'd avoid this unless you want the experience.)
2. This is working properly. The stream functions work by looking for whitespace as separators.
I'd use getline instead. But you will need another buffer. getline does not use std::string.
const int MAX = 200;
char buffer[MAX];
cin.getline(buffer, MAX);
string s = buffer;
|
|
|
|
|
Sorry, screwed up on #2.
You can do getline with a std::string.
const int MAX = 255;
string s;
s.resize(MAX);
cin.getline(&s[0], MAX);
cout << s << endl;
|
|
|
|
|
Hi,
I like to know how can I get a pointer to a particular Document.
I can iterate through my open document and get a pointer to anyone of them.
but at the same time I like to get a pointer to the view of that document as well.
the following code is how to get a pointer to a particular document.
CMyDoc* CMyView::GetDocumentIndex(int n)
{
int i=0;
int nDocCount=0;
CWinApp* pApp = AfxGetApp();
CMyDoc *pCurrDoc;
POSITION posTemplate = pApp->GetFirstDocTemplatePosition();
while (posTemplate)
{
CDocTemplate *pDocTemplate=pApp->GetNextDocTemplate(posTemplate);
if(NULL!=pDocTemplate)
{
POSITION posDoc = pDocTemplate->GetFirstDocPosition();
while(posDoc)
{
CDocument *pDoc = pDocTemplate->GetNextDoc(posDoc);
if(NULL!=pDoc)
nDocCount++;
if(nDocCount == n)
{
pCurrDoc =(CMyDoc*)pDoc;
//this is where I have to get a pointer to the View of pCurrDoc,,,but how?
}
}
}
i++;
}
return pCurrDoc;
}
Ehsan Behboudi
|
|
|
|
|
I like to know how can I get a pointer to a particular Document
Are you sure? The rest of your post describes problems with getting pointers to views. If this is the case, use CDocument::GetFirstViewPosition and GetNextView.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Do I have to get position of the first CView,
then iterate through the rest fo the Views??
Ehsan Behboudi
|
|
|
|
|
|
I used this, but it doesn't work,, any ideas???
CMyView CMyDoc::GetView(int n)
{
int ViewCount=0;
POSITION pos = GetFirstViewPosition();
while (pos)
{
CMyView *ppView=GetNextView(pos);
if(NULL!=ppView)
{
POSITION posView = GetFirstViewPosition();
while(posView)
{
CMyView *pView = GetNextView(posDoc);
if(NULL!=pView)
ViewCount++;
if(nDocCount == n)
pCurrView =(CMyView*)pView;
}
}
}
return pCurrView;
}
Ehsan Behboudi
|
|
|
|
|
|
Hi,
I like to know, how can I open a blank document from my CView class.
I mean actually write the code for ID_FILE_NEW.
I tried the following code, but it doesn't work.
CWinApp* pApp = AfxGetApp();
pApp->OpenDocumentFile(NULL);
thanks
Ehsan Behboudi
|
|
|
|
|
Could anyone tell me if there's an easy way to convert date/time from CString to CTime?
I would, for example, like to convert the string "2001-07-26 14:37:00" to a CTime object. I could do this using string operations to parse out the year, month, etc.. This, however, does not feel like a good solution since it's not very flexible. I would have to include several if-statements in the parsing to be able to handle dates on other formats, like "2001-07-26", "2001-07-26T14:37", etc.
What would make me very happy is if there's a way to use formatting string to specify the format of the input. Like when I convert a CTime object to a CString using Format() with formatting codes like %Y, %m, etc.
Maybe somebody has written a class, derived from CTime, that could handle this?
Jimmy Ehrnström
|
|
|
|
|
You can use COleDateTime::ParseDateTime( string ) to convert the string into the underlying DATE object.
If you don't like to use COleDateTime objects and need the CTime object, you would have to convert between the two. Create a tm structure and populate the structure from the COleDateTime object and then using mktime( tm ) assign the result to the CTime object.
|
|
|
|
|
|
hi,
I'm building a web browser, and I need to provide Java Console Option as IE provides, How could I do it...?
Gaurav Lambole
webdunia.com (India) pvt.ltd.
|
|
|
|
|
Hello,
How can I place the entire contents of a RichEditView into a variable? I can do it if the user selects the text, but I would like to do it unselected.
Also, is there a limit to the size of a string stored in a CString variable?
Thanks!
Frank
|
|
|
|
|
I guess you could use GetRichEditCtrl to get the control associated with the view and then GetWindowText.
/Per
|
|
|
|
|
Thanks, I'll give that a try.
Frank
|
|
|
|
|
How can i link DB grid to DAO database ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi,
how to make a program startup screen where an image is displayed.
Please help me quick.
Thank You
|
|
|
|
|
From VC++ menu select Project/Add to project/Components and controls/VC++ components/Splash screen
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|