|
Hi !
Try this:
void find(CString& s, int n);
for (i = 0, i<=3, i++)
{
//blah blah
CString str ;
str.Format("%d", i);
find(str, nLevel);
// blah blah
}
===========================
Is it possible to pass formatted string to functions?
//function prototype
void find(CString s, int n);
//code 1
//this is what I want to implement
find("0=", nLevel);
// do something
find("1=", nLevel);
// do something
find("2=", nLevel);
// do something
// code2
// to implement the above in a for loop
// can I do something like this?
for (i = 0, i<=3, i++)
{
//blah blah
find("%d=" i, nLevel);
// blah blah
}
code 2 obviously doesnt work, but is there any other way I can implement code 1?
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@mailru.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
try something like:
void findV (LPCSTR szFormat, int nLevel,...)
{
va_list argList;
va_start(arglist, nLevel);
CString str;
str.FormatV (szFormat, argList);
va_end(argList);
find(str, nLevel);
}
you can then do
for (int x =0; x<3; x++)
{
findV("%d=", nLevel, x);
}
The nLevel in there makes it kind of odd. If this is an out parameter you might want to change it to a return value.
|
|
|
|
|
Hello everyone!!!!
I've to capture the window messages of programs in execution from my application developed in Visual C++ 6.0.
I'd like to access to the window text and buttons text of any message error. How could I do this?????
Thanks in advance.
|
|
|
|
|
Hi !
Take a look at hooks.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@mailru.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Could you have more details in relation to your answer or sample code, please??
Thanks in advance,
LuisFer.
|
|
|
|
|
Using SetWindowsHookEx you should set global hook. Hook procedure should be placed in DLL.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@mailru.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Using SetWindowsHookEx you should set global hook. Hook procedure should be placed in DLL.
Use WH_CALLWNDPROC hook type to intercept messages.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@mailru.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Thank you for your previous answer, but I need more information or sample code about "Hooks" taking into account my knowledge of Visual C++. I've seen the SetWindowsHookEx function but I don't understand how to use it.
Thanks in advance and best wishes,
LuisFer.
|
|
|
|
|
I took a look, I saw a nook, and on his head he had a hook. On his hook, he had a book, and on his book said how to cook. But a nook, can't read, so a nook can't cook, so what use to a nook is a hook cook book ?
Sorry, it's early Friday....
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
If you don't want to program, you can use the Spy++ tool with ships with VC++.
You can use it to detect all messages received by the window you can inspect.
Regards
Luis
|
|
|
|
|
can't get this code working.
DWORD fileLength = workFile.GetLength(); //line 1
char fileBuf[fileLength]; //line 2
workFile.Read(fileBuf, fileLength); //line 3
compiler says (all for line 2):
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'fileBuf' : unknown size
|
|
|
|
|
Hi !
Try this:
DWORD fileLength = workFile.GetLength(); //line 1
//char fileBuf[fileLength]; //line 2
char * fileBuf = new char[fileLength];
workFile.Read(fileBuf, fileLength); //line 3
....
delete[] fileBuf;
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@mailru.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
thanz.. that solved part of the problem.. now the compiler says that fileBuf is undeclared (line 2)
*confused*
|
|
|
|
|
correction to my previous post ... the error lies in the line:
delete[] fileBuf;
it says identifier undeclared.
|
|
|
|
|
please ignore all my previous post.. the problem is fixed.. overlooked some areas..
thanz a lot for your help!
|
|
|
|
|
If I make the broadcast to a real nameserver it is ok. If I give INADDR_BROADCAST , no one response. Kindly help to me.
Thankyou
Anita Eugene
|
|
|
|
|
my code is below, there is no compiler error, but when i run the exe file, it says "An unknown errro occurred while accessing C:\myfile.txt"
can anybody help me?
CStdioFile workFile;
CFileException e;
CString filepath = m_tsfFilepath;
if(!workFile.Open(filepath, CFile::modeWrite | CFile::shareDenyWrite, &e ))
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
}
int pos = 0;
CString workString("");
CStringArray aRegisterList;
workFile.Seek(pos, CFile::begin); //position pointer to beginning of file
workFile.ReadString(workString); //read the first line of text
thanz in advance!
|
|
|
|
|
The thing that jumps out at me is that you are opening the file with flags set for WRITE not READ.
I'll confess I did not thoroughly step through your code simply because I noticed that right away.
I hope that's it because that's easy.
|
|
|
|
|
thanz man! how stupid of me!
|
|
|
|
|
I find that the majority of the problems I have are for just such "simple" oversights.
I'm glad it helped.
|
|
|
|
|
In my message map...
BEGIN_MESSAGE_MAP()
...
ON_WM_????
END_MESSAGE_MAP
what is the message used to tell a window to assert the OnRecieve method of a CAsyncSocket object.
|
|
|
|
|
G'day,
I'm using a CTreeCtrl with check boxes on each item in a dialog. During to call to the dialog's OnInitDialog() I set up the initial checked/unchecked status for each tree item, but these checks seem to disapear when the dialog is actually displayed.
I've poked around in my code and it seems that the checked status is actually lost for each tree item some time after OnInitDialog() returns.
I can check/uncheck tree items with the mouse after the dialog is displayed, but it just seems to lose the checks when initializing.
Can anybody point me in the right direction, please?
I'm sure this has been discussed here at CP before, but I can't find any references.
TIA,
Steve
|
|
|
|
|
Some code please - OnInitDialog handler would be best.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
G'day Tomasz,
I won't post my actual code here (it's way too long), but the following snippet has the same effect. Note, I've set up the tree control in the dialog as having check boxes enabled.
BOOL CReportSettingsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString strItemName;
for(int i = 0; i < 20; i++){
strItemName.Format(_T("Item%d"), i);
HTREEITEM hItem = m_Tree.InsertItem(strItemName);
ASSERT(NULL != hItem);
m_Tree.SetCheck(hItem, TRUE);
}
return TRUE;
}
When the dialog above gets drawn, the tree displays the inserted items, but none of their check boxes are checked.
TIA,
Steve
|
|
|
|
|
The solution is quite funny. Here's what I found in the "Tree View Control Window Styles" at MSDN:
"TVS_CHECKBOXES:
...
If you want to use this style, you must set the TVS_CHECKBOXES style with SetWindowLong after you create the treeview control, and before you populate the tree. Otherwise, the checkboxes might appear unchecked, depending on timing issues."
To solve the problem, you have to:
(1) clear the 'check boxes' option in the tree control properties in dialog editor
(2) programatically set the style after the window is created and before items are inserted:
m_Tree.ModifyStyle(0, TVS_CHECKBOXES);
for (...)
{
m_Tree.InsertItem(...);
m_Tree.SetCheck(...);
}
(2) is not enough (at least on my W2K box) - you can't have your tree control created with TVS_CHECKBOXES style.
Cheers,
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|