|
If you watch the messages to the Progman window (using Spy++), you can see that WM_USER+83 is sent during this action. If you could track this, I think you will get what you are seeking.
- ns ami -
|
|
|
|
|
I have no idea of Spy++ can u please explain me with any example or exaplain me step by step how can i use this.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Spy++ is available with Visual Studio Tools. You will get it from "Start Menu\Programs\Microsoft Visual Studio 6.0\Microsoft Visual Studio 6.0 Tools". Using the Spy++ is documented in its Help.
- ns ami -
|
|
|
|
|
You've asked about Spy++ before.
1/ Find it in the IDE's menu.
2/ Run it.
3/ Play with it.
4/ Remember results of the playing.
This is called learning, and is very useful.
More seriously, it is a very useful tool to know, and you should make working with it a priority.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi All
How can i filter text file?I have a file Test.txt which have some data like this.
abc
abc
12121
12121
12
12
133
133
133
Now i want to show data on Button click like this
abc
12121
12
133
Plz help me...
|
|
|
|
|
One alternative is to put the read string into a map. Once you do this, go and read the next string from the file. If this string exists in the map ignore it and do not put it in the map and so on. While displaying, display only the elements present in the map.
Hope it helps
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Read line by line into an STL list class and call the unique method.
Call the sort method before unique if the data is not already sorted.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
can you give me example.Plz
|
|
|
|
|
He needs you do his homework... I guess.
- ns ami -
|
|
|
|
|
Hello rdop,
You can use std::set to remove duplicate entries. This link will be useful - link[^].
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
BOOL flag;
flag=FALSE;
CStdioFile file;
CString str,str2;
str=str2=_T("");
file.Open(_T("G:\\Test.txt"),CFile::modeRead |CFile::typeText ,0);
while(file.end)
{
file.ReadString(str);
if(!str.Trim().IsEmpty())
{
if(flag==FALSE)
{
CStdioFile file1;
file1.Open(_T("G:\\final.txt"),CFile::modeCreate|CFile::modeWrite|CFile::typeText ,0);
file1.Seek(0,CFile::end);
file1.WriteString(str);
file1.WriteString(_T("\n"));
file1.Close();
flag=TRUE;
}
if(file_read_write(str)==FALSE)
{
CStdioFile file2;
file2.Open(_T("G:\\final.txt"),CFile::modeWrite|CFile::typeText ,0);
file2.Seek(0,CFile::end);
file2.WriteString(str);
file2.WriteString(_T("\n"));
file2.Close();
}
}
else if(str.Trim().IsEmpty())
{
break;
}
}
file.Close();
ShellExecute(NULL,_T("open"),_T("G:\\final.txt"),NULL,NULL,SW_SHOW);
BOOL file_read_write(CString string);
BOOL Ctest::file_read_write(CString string)
{
BOOL flag=FALSE;
CStdioFile file;
CString str1;
str1=_T("");
file.Open(_T("G:\\final.txt"),CFile::modeRead |CFile::typeText ,0);
while(file.end)
{
file.ReadString(str1);
if(!str1.Trim().IsEmpty())
{
if(_tcscmp(string,str1)==0)
{
flag=TRUE;
break;
}
}
else
{
break;
}
}
file.Close();
if(flag==TRUE)
{
return TRUE;
}
else
{
return FALSE;
}
}
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hi All,
im working on a dialog based application in vc6.0.
My project consists of 15 files in which i need to convert 4 files
in to a library.
Is it really possible to convert only part of code in to a library, by keeping rest of the code as it is??
Or do i need to remove those 4 files and built them in to a separate work space as
library and add it to the complete project?
If I can do it, please give me the steps to do it.
Regards,
Sunil Kumar
|
|
|
|
|
2 words : design, architecture
given you've told us diddly squat about what your dialog app is doing, its a bit hard - but the answer could be 'yes'
15 files ? it really depends on the functionality - whats in the '4' files that makes them special ?
If its a data processing/reformatting app for example, you may be able to seperate out the number crunching or string reformatting into a library/dll. You could even put your MFC stuff in an MFC Extension ...
But likely you are going to need to do some 'refactoring' so
sunilkumar.d wrote: Or do i need to remove those 4 files and built them in to a separate work space as
library and add it to the complete project?
is also going to have to happen
So, suggestions ...
Isolate your functions ? in 4 files into a seperate project, build a dll
build a test harness for the dll and test it
then IN A COPY of your dialog app, graft in the dll
test test test
next time, think about the design a bit harder ..
thats still going to be a bit of work, but if for example you will want to use those functions again/elsewhere, you've done the hard bits ...
'g'
|
|
|
|
|
Thanks Garth for your valuable suggestions.
Actually I need to hide those files when I am giving the source code to client.
Thats why I need to make them in to library.
Anyway I think i need to redesign my Code for this to happen.
Regards,
Sunil Kumar
|
|
|
|
|
sunilkumar.d wrote: My project consists of 15 files in which i need to convert 4 files
in to a library.
That should be doable. So long as the files are in separate source files, you should be able to put them in a static library that you link into the application (it's not particularly different from just linking in the object files directly).
sunilkumar.d wrote: Or do i need to remove those 4 files and built them in to a separate work space as
library and add it to the complete project?
I'd remove those source files from the original project, add a new static library project to the solution and add the source files to that.
Remember that you'll still need to ship the header files that declare the items defined in the source files.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Visual C++ and Microsoft Excel
I am working on a project at the moment and have an issue with reading MS Excel 97 ~ 2003 spreadsheets.
My problem relates to the Excel field format of any given field in the spreadsheet, if a field is formatted in Excel to anything other than Text, then I cannot read the data from that field. for example if column A1 is formatted in excel to Text (good data returned) if A2 is formated to a number (a null is returned) if A3 is text (good data is returned), and so on.
The problem seems to be getting my code to understand the format of any particular field, Here is a snipped of my code;
1) I am using the CRecordset class to open and read the Excel spreadsheet. The spreadsheet has
defined name ranges and generally all works just fine (Provided the fields are text formatted).
2)If i use this line of code to first attempt to read what type of data is in a NUMBER field
"recset.GetODBCFieldInfo( m_csaColumnNames.GetAt(i), fieldinfo );"
I get a positive response when i try the different data types
"if(fieldinfo.m_nSQLType == SQL_VARCHAR){AfxMessageBox("SQL_VARCHAR");}"
suggesting its a data type SQL_VARCHAR data type
3) If i then call GetFieldValue to get the info from a field with a switch command
CDBVariant variant;
recset.GetFieldValue( m_csaColumnNames.GetAt(i), variant);
switch(variant.m_dwType)
{
case DBVT_SHORT:{ szValue.Format("%d", variant.m_iVal);
break;
}
case DBVT_LONG:{ szValue.Format("%d", variant.m_lVal);
break;
}
case DBVT_SINGLE:{ if ( variant.m_fltVal == 0.0 )
szValue = "Verify";
else
szValue.Format("%.1f", variant.m_fltVal);
break;
}
case DBVT_DOUBLE:{ if ( variant.m_dblVal == 0.0 )
szValue = "Verify";
else
szValue.Format("%.1f", variant.m_dblVal);
break;
}
case DBVT_DATE:{
szValue.Format("%B %d, %Y",variant.m_pdate );
break;
}
case DBVT_STRING:{ szValue = *variant.m_pstring; //szValue = V_BSTRT( &varValue );//convert BSTR to CString
break;
}
case DBVT_BOOL:{ if(variant.m_boolVal)
szValue = "TRUE";
else
szValue = "FALSE";
break;
}
case DBVT_UCHAR:{ szValue = (char*)variant.m_chVal;
break;
}
case DBVT_NULL:{
szValue = "Error Null"; AfxMessageBox(szValue);
break;
}
default:{
szValue = "\0";
break;
}
}//switch
RESULTS
All fields which are text, return a valid value which is exactly as per the Excel Spreadsheet, all fields which contains numbers or I even tried date formats in excel return DBVT_NULL which is totally useless because the cell has a number in it or a date.
SUMMARY
I have tried to read the data using GetODBCFieldInfo only and then calling the m_ member depending on the type returned which i know to be in the field, but that does not give me anything other than an unsigned short with random values that bear no resemblance to what is in the actual field.
Any help that anyone can offer in regards to solving this problem would be much appreciated and I I can get the entire class working properly I have happy to post it here for all to use.
Thanks in advance for any assistance.
|
|
|
|
|
|
I'm using fread to read a xml file with utf-8 encoding. I set up Mutil-byte character set in VS2005. Now there are several 2 bytes unicode characters inside the file and the program is using char*. The progam reads the file quite OK, only when it encounts those unicode, it seems each 2 bytes unicode characters are sperated into 2 chars, and becomes unreadable character each. I just wonder how this could happen? And is there any way to solve this problem?
|
|
|
|
|
See a similar thread.[^] Hope it helps.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
I have an application which uses the win API GetShortPathName to get the short path(8.3) from a long path.
The string is terminated with a '\'. Yet the path returned is not a short path. Is there any association with the registry key NtfsDisable8dot3 or does anyone have any idea as to what could be the reason of its not working. The platform is windows 2003.
|
|
|
|
|
tom groezer wrote: Is there any association with the registry key NtfsDisable8dot3
Yes - the first Google hit for 'NtfsDisable8dot3'[^] could have told you that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Is there any other reason for such behavior
|
|
|
|
|
For starters:
- The filesystem on which the file resides does not support short filenames (so, NTFS with the registry key we talked about, HFS+, extfs via a network connection)
- The file doesn't exist - it has to for
GetShortPathName to work
Did you check the extended error information (with GetLastError ) to see what error was signalled?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have written a small C++ program using Visual Studio 2008. I use the resource editor to create some menus and then look for the appropriate events in the callback routine to perform whatever action is needed when a certain menu item is selected (part of the callback routine is below):
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
int wmId;
switch (message) {
case WM_COMMAND:
wmId = LOWORD(wParam);
// Parse the menu selections:
switch (wmId) {
case ID_TOOLS_INITIALIZECOMPORT:
SetupStuff();
initialized = true;
break;
case ID_TOOLS_CALIBRATE:
reCalibrate();
break;
...
I'd like to know how to modify the properties of the menu items from the code (for example changing the text or setting a check-mark etc) but since I used the resource editor to create the menus I don't know how to get their handles or how to access their properties - all I know for each menu item is its ID.
I'm sure I'm just being stupid but any advice would be greatly appreciated.
Mats
|
|
|
|
|
If it's the same as the sample I just created, you specify the menu in the window class:
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_XX));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_XX);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
To get the menu for a window of this class, use GetMenu[^] using the window handle.
[edit]Here's a sample commnd handler (insert in a switch statement like the one you have in your post) that inverts the checked state for a menu item (ID_FILE_TESTITEM) when the menu item is selected. This does assume that the File menu is the first sub-menu on the menu bar.
case ID_FILE_TESTITEM:
{
HMENU menu = GetMenu(hWnd);
menu = GetSubMenu(menu, 0);
const bool checked = (GetMenuState(menu, ID_FILE_TESTITEM, MF_BYCOMMAND)&MF_CHECKED)==MF_CHECKED;
CheckMenuItem(menu, ID_FILE_TESTITEM, MF_BYCOMMAND | (checked?MF_UNCHECKED:MF_CHECKED));
}
[/edit]
PS - any reason you're using raw C/C++ rather than a framework (WTL or MFC)? They do make it easier to do all this, honest
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Sunday, March 1, 2009 4:25 PM
|
|
|
|