|
newbie beware,
how could i convert this CString for an encryp routine?
CString tm;
tm = "Hello";
i've tried this, and everything else i could think of:
LPTSTR lpsz = new TCHAR[tm.GetLength()+1];
_tcscpy(lpsz, tm);
TCHAR HelloCrypt[] = lpsz;
i get, "can't convert char* too char[]"
any helps really appreciated.
shotgun
|
|
|
|
|
shotgun wrote:
TCHAR HelloCrypt[] = lpsz;
You can't assign a pointer to an array.
Should be:
LPTSTR HelloCrypt = lpsz;
TCHAR HelloCrypt[] = "Hello" is possible, because it's constant known at compile time.
It's not VB, at runtime you must create arrays of unknown size using new.
Pavel
Sonork 100.15206
|
|
|
|
|
figured it out
changed
TCHAR HelloCrypt[] = lpsz;
to
TCHAR *HelloCrypt = lpsz;
is there a better way or is this correct?
shotgun
|
|
|
|
|
If the input parameter of your routine is constant, you can pass directly the CString variable, CString has an LPCTSTR() operator defined.
If your routine need to write into the string data, you can use CString::GetBuffer/ReleaseBuffer methods.
Pavel
Sonork 100.15206
|
|
|
|
|
i have a problem with irda/connect: the code is
if (connect (sock, (struct sockaddr *)&address,
sizeof (SOCKADDR_IRDA)) == SOCKET_ERROR)
{
wsaError = WSAGetLastError();
}
wsaError returns WSAEINVAL;
There is some link that help me!
|
|
|
|
|
Anonymous wrote:
There is some link that help me!
That is correct, and I can't for my life understand why you haven't used it yourself!
|
|
|
|
|
I have an application with an MDI Doc/View architecture, and I want to call MDITile() every time I open a new unique document, so that it automatically tiles all documents.
Problem is, when I call it from within CMainFrame::PreCreateWindow, i keep getting assertion errors (wrong object type). Also, having problems getting a handle to CMDIFrameWnd() outside of my mainframe.cpp file.
Help! When/where/how should I be calling MDITile() ??
|
|
|
|
|
FlyingWren wrote:
when I call it from within CMainFrame::PreCreateWindow, i keep getting assertion errors
You can't call it from CMainFrame::PreCreateWindow. The application windows are not created yet, that's probably cause of the assertion.
FlyingWren wrote:
Also, having problems getting a handle to CMDIFrameWnd()
AfxGetMainWnd() returns the CMainFrame pointer for MDI application.
Pavel
Sonork 100.15206
|
|
|
|
|
FlyingWren wrote:
I have an application with an MDI Doc/View architecture, and I want to call MDITile() every time I open a new unique document, so that it automatically tiles all documents.
Problem is, when I call it from within CMainFrame::PreCreateWindow, i keep getting assertion errors (wrong object type). Also, having problems getting a handle to CMDIFrameWnd() outside of my mainframe.cpp file.
CMainFrame::PreCreateWindow() is way too early. Have a look at doing it in CChildFrame::ActivateFrame()
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Hello,
I am trying to develop a function that accepts one pointer to a character array, and takes out all of the white spaces in the array leaving only the characters in the same sequential order. However, I want to accomplish this by only using the one pointer passed to the function. I know this is probably not the best way to accomplish this but I know it can be done somehow. Any suggestions and help would be greatly appreciated. Thanx
I Am trying to figure out how to do this by not declaring another pointer, or variable of any type in the function.
This just seems kinda more interesting to me.
codefun
|
|
|
|
|
Homework?
void skipspace(char* txt)
{
char *to = txt;
char *from = txt;
do
{
while(isspace(*from)) from++;
if(to!=from) *to = *from;
to++;
from++;
}
while(*to);
}
Pavel
Sonork 100.15206
|
|
|
|
|
Intellect559 wrote:
However, I want to accomplish this by only using the one pointer passed to the function. I know this is probably not the best way to accomplish this but I know it can be done somehow. Any suggestions and help would be greatly appreciated. Thanx
Just use a loop to sequentially search through the array, placing the non-whitespace characters into a temporary arry of the same size as the one passed to it... then just copy the temp array back over the original one. Shoudl do the job for you
Regards,
Brian Dela
|
|
|
|
|
And allocate an extra array just for that job?
What about something like
foo(char *s)
{
char *mid = s;
while (*(s++) != ' ')
{
if (s == '\0')
{
break;
}
*(++mid) = s;
}
}
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Duh brian... sorry. My brain has been on a go slow for the last 3 months, or so
Regards,
Brian Dela
|
|
|
|
|
Assuming you function is
fn(char* p)
just get a local pointer that you initialize to "p", and whenever you reach a non-space you
*p++ = *local++;
and whenever it is a space you just increment "local".
|
|
|
|
|
Hello,
I want to resize an edit control in my Cdialog derived class :
void CMyDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
GetDlgItem(IDC_EDIT_TEXT) -> SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOOWNERZORDER);
}
But my app crash... why ??
|
|
|
|
|
The OnSize is first called, before the dialog window is displayed and GetDlgItem returns NULL.
Pavel
Sonork 100.15206
|
|
|
|
|
Hello, I need to be notified somehow when the mouse hovers above
a button on my toolbar and I need to know which button it hovers
above. I was under the impression that if I created the toolbar
with the style TBSTYLE_REGISTERDROP I could catch TBN_GETOBJECT, but
it never gets generated, it seems. What is the most straightforward way
to accomplish this?
// William Payne
|
|
|
|
|
catch the WM_MOUSEMOVE message for your button:
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
|
|
|
|
|
In Some websites I get this message(box), How do I get rid of this?!
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
IE->Tools->Internet Options->Advanced->Browsing->Disable script debugging should help.
Pavel
Sonork 100.15206
|
|
|
|
|
When I loaded the ".dsw" file into the VC++ IDE, a message popped up saying that VC++ was unable to load the ClassView information file.
Yes, there was no ClassView information shown after the loading took place, though ResourceView and FileView were present!
Might anyone know why this occurred, and how I may get back ClassView? I did try reloading the program several times, but each time it was the same.
Thanks!
William
|
|
|
|
|
I'm assuming you're referring to VS6.
Usually this problem is caused by your classview file (.ncb) being read-only, check for this first of all. Otherwise delete any existing .ncb file and restart VS, it will then rebuild the classview file from scratch.
Hope this helps,
Jason.
modified 10-Jul-19 21:02pm.
|
|
|
|
|
This can also happen when you have more than one instance of the IDE openning the same workspace.
Gary R. Wheeler
|
|
|
|
|
You have an interesting point there, because while there are two distinct projects being worked on (residing in two separate directories, with different names) the files both projects have, are about 99% the same.
Both projects were loaded into their own respective workspace, but only the first one showed the ClassView. The second project with its different name, located in a different directory and loaded into its own workspace, did not show its ClassView.
William
|
|
|
|