|
Hello,
I have a function that calls a compare function which does a simple strcmp() comparison. Then in this function I return to the calling function the value of result.
this is my compare function:
bool m_Sensitive = false;
int result;
char lino[] = "value";
if (! m_Sensitive)
{
result = strcmp(lino,Src);
}
else
{
result = strncmp(lino,Src,strlen(lino));
}
return result;
Back in the calling function which returns a bool I need to analyze the return value.
I have tried
if (return !=0)
return false;
else
return true;
this is not working any thoughts?
thanks,
Lino
|
|
|
|
|
return m_Sensitive ? strncmp(lino, Src, strlen(lino) ) == 0 : strcmp(lino,Src)== 0 ;
returns TRUE if the strings match else FALSE
|
|
|
|
|
You've not indicated what is not working. The code snippet you've shown is syntactically correct.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
In MS Visual C++, how do I gray out a dialog's radio button *IN CODE* as opposed to using the resource editor?
|
|
|
|
|
Call EnableWindow(FALSE) .
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David! I used the following code...
GetDlgItem(IDC_RADIO1)->EnableWindow(FALSE);
|
|
|
|
|
Like this ...
<br />
void CMyDlg::EnableField(UINT nID, BOOL bEnable)<br />
{<br />
CWnd *pWnd = GetDlgItem( nID );<br />
ASSERT( pWnd );<br />
pWnd->EnableWindow( bEnable) ;<br />
}<br />
<br />
EnableField( IDC_RADIOxxx, FALSE);
Uncomment the ShowWindow statement to re-inforce the fact that a dialog window is disabled by hiding it.
|
|
|
|
|
Thanks mtzlplyk! Useful code there!
|
|
|
|
|
I am having trouble getting my Picking code to work in collaboration with glUnProject. The picking will work with the use of glUnProject but I need it to work for me. anybody else run into that?
|
|
|
|
|
Hi.
I’m a VC++ developer that is going to distribute exactly 10 licenses of an ActiveX control I’ve done. I would like to make the ActiveX itself freely available on for e.g. a public ftp-server. So, about 100 users have may installed my ActiveX but because my customer just bought license for 10, only 10 users should bee able to use it at the same time.
I’ve figured of this a lot and have found out that all controls may have some connection to a server that “allow” them to run. If that’s a good thought, how should I design that “server-program”?
Would be very pleased of tips of where to find different ways to handle license and login techniques!
In which way is preferred to handle my problem? All thoughts are helpful!
_____________________________
...and justice for all
APe
|
|
|
|
|
I have written an MFC App that will display a hard coded menu item CString to the DC (the screen) in 3 diffetrnt RGB values using 'Set' and 'Get' functions to randomize the color. I have a random number generator that passes the value to a switch statement with RGB colors.
I now want to change the code to rendomize the color of EACH INDIVIDUAL CHARACTER in the string, as opposed to having the whole string the same color.
If some one could send a code fragment to access each character in s CString.
I'm using DrawText to display.
- thanks for your help
|
|
|
|
|
SkunkedWorks wrote:
If some one could send a code fragment to access each character in s CString.
No special code required. Just use the [] operator or the GetAt() method.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks.
So... say I have this:
CString str("abc");
What would the syntax look like if i used GetAt()?
|
|
|
|
|
TCHAR c = str.GetAt(0 );
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David - that's EXACTLY what I was looking for. When I searched for it in MSDN it kept giving me a reference to a CHString (whatever that is..)
|
|
|
|
|
It's similar to CString but without MFC's overhead. The WMI classes seem to make extensive use of it.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Or, to get a:
str[0];
for b:
str[1];
and so on
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
bdiamond
|
|
|
|
|
Dear All
I have an ActiveX control in Visual Basic (an enhanced flexgrid ocx). I am using this control in an VC++ application (dialog box app).
The control has a context menu, having options like cut, copy, paste etc. This menu is invoked when i right click on the control.
I want to use the cut and paste options using the context menu, to cut and paste data available in the control into the cells of the control.
The problem that I am facing is that, when click on the menu items, the event is raised in Visual Basic, but I want to make that event available in VC++ to move data to and from the Clipboard.
Any help available would be greatly appritiated.
Thanks in Advance...
Manoj
|
|
|
|
|
I have two processes (both written by me, i.e. I can modify them at will). When bot are already running, one (the server) needs to create a COM object, and pass an interface to the other (Client).
My only problem: how do I get one interface (IUnknown) marshaled to the other process?
(*using* a COM object in another process I already tried a few times, but they were always instantiated using CreateInstance)
I *think* I have to register the object in the Running Object Table (ROT), and notify the client that it's now there. However, I never really understood this Moniker business (beyond being, well, a Moniker), and I can't find a default implementation that seems usable out of the box.
is the ROT the right way? What Moniker?
additional info: The client will control the server, but I have some external requirements not solvable through COM, which force me to create the process manually. Also, there should be multiple Client/Server pairs (or even One client with multiple servers) possible, I guess differen monikers could solve that...
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
I do it like this ...
ServerFunc(LPDISPATCH *p)<br />
{<br />
CMyClass object;
LPDISPATCH lpDisp = object.GetIdispatch(TRUE);
*p = lpDisp;<br />
}<br />
<br />
<br />
#include "server.h"
void foo()<br />
{<br />
LPDISPATCH *lpDisp<br />
ServerFunc( &lpDisp );<br />
IMyClass *pMyClass = new IMyClass(lpDisp);<br />
}
It works for me
|
|
|
|
|
The problem for me is: ServerFunc runs in a different Process, so I just can't pass the IDispatch * this way.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
I am trying to access the StudentTable in an Oracle database, I have set the data source correctly. There is also no errors reported
after I built the exe file. but when I ran the exe, I can see the messagebox showing the "connectinon to the database succeeds." In the following step, there is
a messagebox with title "Microsoft Visual C++ Runtime Library" showing "Runtime error ...".
I don't know where is wrong , here is the code, who could tell me where is wrong? Thanks.
BOOL flag=FALSE;
flag=m_db.Open("MyDSN",FALSE,FALSE,"ODBC;UID=user1;PWD=userpwd",TRUE); //m_db is a CDatabase member object.
if(flag)
AfxMessageBox("connectinon to the database succeeds.");
else
AfxMessageBox("connectinon to the database failed.");
CRecordset rs(&m_db);
try
{
if(rs.IsOpen())
rs.Close();
if(rs.Open(AFX_DB_USE_DEFAULT_TYPE,_T("select * from user1.StudentTable"),CRecordset::readOnly))
AfxMessageBox("Recordset has been opened!");
}
catch(CDBException e)
{
e.ReportError();
AfxMessageBox("Failed to open the recordset");
}
|
|
|
|
|
Have you single-stepped through the code to see which statement is causing the error?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
I am writing software that parses out an RTF file. One of the things I want to do is extract pictures and save them to a file. The following is taken directly from Microsoft's RTF FAQ (version 1.3):
---- From RTF FAQ ---
The picture in hexadecimal or binary format follows the picture-destination control words. The following example illustrates the destination format:
{\pict\wbitmap0\picw170\pich77\wbmbitspixel1\wbmplanes1\wbmwidthbytes22
\picwgoal505
\pichgoal221
\picscalex172
\picscaley172
49f2000000000273023d1101a030
3901000a000000000273023d98
0048000200000275
02040000200010275023e000000000
273023d000002b90002b90002
b90002b90002b9
0002b90002b90002b90002b90002b90002
b92222b90002b90002b90
002b90002b9
0002b90002b90002b90002b9000
---- End of Stuff from RTF FAQ ---
I am able to parse out all of the bytes (in this example, beginning 49f2...) and I convert them from their text representation to real bytes (i.e., the character sequence "49" is converted to 0x49), but what I get is not a readable picture.
Here is more detail: Suppose I have a bitmap file. I take the same picture and embed it in an RTF document. I can open up the document in Notepad and view the hexidecimal represeantion of the image. I have also written a program that can read a binary file such as a bitmap and convert it to the text equivalent of a hexidecimal as it would appear embedded in the RTF document. I then visually compare the hex I generated directly from the hex embeded in the RTF file.
The hex from the RTF file is the same as the hex I generate directly from the disk file... EXCEPT for the first several hundred bytes! Each source starts out different, but after a hundred byts or so, each is then the same, so I know my encode/decode should be working.
But why is the hexidecimal of the embedded picture not exactly the same as the hexidecmal of the disk file? According to the RTF FAQ, they should be. What can I do to extract the picture? Did Microsoft do something to encode the first series of bytes for a picture so that no one else can extract it?
I have found this problem with both bitmaps and GIF files. I am using MS Word 95 to generate the RTF files with pictures embedded.
|
|
|
|