|
James R. Twine wrote: FYMNI, my post was a reply to someone other than the OP. My post addressed the incorrect parts of the provided solutions, as well as provided some background that will hopefully get others to learn more and thus become better developers.
You see, some of us are capable of learning something even if provided out of context, and some... as recently demonstrated... simply are not.
I wasn't trying to discount what you were saying (nor the discussion) ... just mentioning that the original problem had nothing to do with this line of discussion.
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
|
|
|
|
|
Zac Howland wrote: I wasn't trying to discount what you were saying (nor the discussion) ... just mentioning that the original problem had nothing to do with this line of discussion.
Understood... Tone lowered...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
You are going to have a couple problems here:
1) When using scanf-derivatives, the %s directive doesn't work quite like you would expect it to. You will probably want to use the %[] directives with the appropriate delimiter, or better yet, write a simple split method that takes a delimiter and splits a CString into a CStringArray. This part of the error will just give you incorrect data.
2) The scanf-methods (as with all C methods) were not designed to work with class objects. You have to give it a pointer to a character buffer. You can either declare a set of char[]'s, or use the GetBuffer/ReleaseBuffer calls appropriately:
CString userInput = _T("");<br />
char device[20] = {0};<br />
char cmd[20] = {0};<br />
char input1[20] = {0};<br />
char input2[20] = {0};<br />
int i = 0;<br />
<br />
i = _stscanf(userInput,_T("%[a-zA-Z0-9] %[a-zA-Z0-9] %[a-zA-Z0-9] %[a-zA-Z0-9]"), device, cmd, input1, input2);
or, alternatively:
CString userInput = _T("");<br />
CString device = _T("");<br />
CString cmd = _T("");<br />
CString input1 = _T("");<br />
CString input2 = _T("");<br />
int i = 0;<br />
<br />
i = _stscanf(userInput,_T("%[a-zA-Z0-9] %[a-zA-Z0-9] %[a-zA-Z0-9] %[a-zA-Z0-9]"), device.GetBuffer(256), cmd.GetBuffer(256), input1.GetBuffer(256), input2.GetBuffer(256));<br />
<br />
device.ReleaseBuffer();<br />
cmd.ReleaseBuffer();<br />
input1.ReleaseBuffer();<br />
input2.ReleaseBuffer();<br />
Passing in the address of a CString object will lead to a stack-corruption and hence your Access Violation.
The old-style C methods (printf, scanf, etc) have been deprecated in VS.Net 2005 (can't remember if they were also in 2003). There is a link in the MSDN documentation that describes their replacements. You can either use those replacements (and avoid the warnings), pragma out the deprecated warnings, or write a split function (which is what it looks like you really want in this case anyway).
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
|
|
|
|
|
God I love you guys!
Kitty5
|
|
|
|
|
I created my own CPropertySheet which is CMyPropertySheet and I created my own CPropertyPage, CMyPropertyPage. CMyPropertyPage is a superclass for my pages. It provides access to CMyPropertySheet which is run from my App like a dialog program runs it's dialog. So CMyPropertySheet holds my state information for filling out the pages as they gather information from the user. I am misunderstanding my compiler because I have the #ifndef __mypage_h__ ... #endif markup so that my files are only included once and still if I add #include "MyPropertySheet.h" to MyPropertyPage.h my project recurses the includes until it gives up. Naturally (to me at least), the sheet knows of the pages so that the sheet can make itself, and the page knows of the sheet so it can store info.
I tried prototyping the classes but I must be doing something improper. An example of a working relationship like this would save me two Aspirins and a morning.
|
|
|
|
|
I ran in to a saomewhat similar situation and to resolve it I removed the include of "MyPropertySheet.h" from 'MyPropertyPage.h" and use a forward reference for CMyPropertySheet instead. Are you able to use a forward reference instead of including the file?
|
|
|
|
|
Thanks, you set me on the path to a buildable project. For anyone who runs into a similar situation, here's what I did.
In CMyPropertyPage's header file, I forward reference "class CMyPropertySheet;", and in CMyPropertyPage's source file, I include CMyPropertySheet (MyPropertySheet.h). Be careful, when forward referencing you cannot use any operations on CMyPropertySheet in the header file. That was throwing me off.
Case closed.
|
|
|
|
|
I'm trying to create a .dll using ATL, which I want use in C#.
Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string)..
I tried a lot but always faced problem of returing string back to calling function in C#.
I did the same with C++ class library successfully but when it comes to ATL its not the same.
As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL.
Now please guide me to create the methods which I can use in C# to get the string value.
Arun
|
|
|
|
|
Write a C++ program to implement this pointer object
Define Class customer containing
Code , Name , Billtotal and member function
Accept()
print()
In the main function declare two or multiple object of the above class
and find out which object contains highest billtotal and print that object
at end , use function prototype given below
customer Highbilltotal( customer &)
Implement object passing as referene and returning object
|
|
|
|
|
|
joyalfernandes wrote: Write a C++ program to implement this pointer object
1. i never talked to you that bad, so change your language please.
2. here at codeproject, people aren't paid for their help, so no one owe you anything.
3. Homework are bad seen here. if you have some homework to do, it's because you have to learn how things are done, so don't ask people to do it for you, this is child thinking.
Think about your problem first, and only then, ask for specific questions if you can do it yourself.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
|
Ya man, the people here are very helpful if you have a specific problem... why not try and tackle it first and come back if you run into major obstacles.
Btw this is pretty impressive
Birthday Tuesday 20th October, 1987
Location India
Occupation Software Components, Web design, Science and Engineering, Systems engineering
Interests C++, WTL, Win32, Managed C++, C#, ASP, ASP.NET, VB6, VB.NET, J#, Javascript, Perl, SysAdmin, Database
|
|
|
|
|
|
|
This will help :
HBRUSH CtestMFCDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor== CTLCOLOR_EDIT )
hbr=CreateSolidBrush(RGB(0,100,0));
return hbr;
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
THANKS A LOT
Please mail me
|
|
|
|
|
<imho>
We should use the reflect message =WM_CTLCOLOR on CMyEdit more OOPs Oriented.
Regards,
FarPointer
Blog:http://farpointer.blogspot.com/
|
|
|
|
|
If you are doing this in OnCtlColor handler for WM_CTLCOLOR notification, and you want to affect the colours of all of edit boxes, then you can try the last argument of OnCtlColor , which describes the type of control:
HBRUSH CMyDialog::OnCtlColor( CDC * pDC, CWnd * pWnd, UINT nCtlColor)
{
if(nCtlColor == CTLCOLOR_EDIT)
{
. . .
}
else
{
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
}
Hope it helps.
|
|
|
|
|
THANKS A ..... ..................LOT
Please mail me
|
|
|
|
|
Add a class variable that holds the color, and for each edit box, modify that variable.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
stop deleting your questions when someone gives you the answer you were looking for.
it's not the first time i say you this, and you still behave like a SELFISH man
if you don't want others to see the answer anymore, then don't ask it here ; find a friend and ask him whatever you like. but here (and in a general mean on forums), things are written to be read after a more or less time since it was written
isn't it Mr. Gourav ?!
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Can we give buffer as input to the ISpRecogniser instead of file. I just want to take the buffer out from a file and give as input to the ISpRecogniser.Is there any function though which we can set the input as buffer.
Plese help me.
Thank you
KIRAN PINJARLA
|
|
|
|
|
Guessing you are using ISpStream::BindToFile function to associate the input audio stream with a file, maybe you can try ISpStream::SetBaseStream to associate it with an in-memory stream created with CreateStreamOnHGlobal ?
|
|
|
|
|
Hi,
I have an application in which I am loading data from a database (in this specific case a large database) into a grid in my GUI. So, I open the query into a recordset using the Open method as follows:
sQuery.Format(_T("SELECT DISTINCT D.fieldA, DC.fieldB
from TableDC DC, TableD D
WHERE D.fieldA = DC.fieldA AND D.No = '3’
ORDER BY DC.fieldB"));
if(!Open(AFX_DB_USE_DEFAULT_TYPE, sQuery, CRecordset::readOnly))
{
...
}
The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok).
Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
|
|
|
|
|