|
You cannot realloc with the standard new operator. You will have to use malloc and realloc if you want to do this.
Or you can allocate a new pointer that is the size that you want, copy the data into that pointer and delete the old pointer.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I can't realloc a managed unsigned char, as far as I know ...
|
|
|
|
|
Well after all this answers ... (???) Because I posted this messages into the wrong FORUM! We really need a MC++ forum!!
Anyway, I created it a MC_realloc(unsigned char __gc[], int len) __gc[]
The pointer return is always different!
I just thought you wanted to know! I hope Chris creates a new MC++ forum soon!
Al
|
|
|
|
|
hi, new at this
what would the code be to start reading at the first letter (pointer maybe)of some text entered into a editbox and then displaying the text + 1 in another box.
thanks
|
|
|
|
|
Hmmm, here is an example...
First, let us assume hWnd1 and hWnd2 are the source and destination windows.
char szText [256];
GetWindowText (hWnd1, szText, 256);
if (strlen (szText) < 255)
{
strcat (szText, "A");
SetWindowText (hWnd2, szText);
}
else
;
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Here is some code for dialog whose handle is hDlg, to read from an edit box called ID_EDIT1, and put the desired text in an edit box called ID_EDIT2:
int iLen;
HWND hEdit1 = ::DlgGetItem(hDlg, ID_EDIT1);
iLen = ::GetWindowTextLength(hEdit1);
if (iLen < 0)
{
return;
}
TCHAR *pszText;
pszText = new TCHAR[iLen+1];
if (NULL == pszText)
{
return;
}
::GetWindowText(hEdit1, pszText, iLen+1);
HWND hEdit2 = ::GetDlgItem(hDlg, ID_EDIT2);
::SetWindowText(hEdit2, pszText + 1);
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I have an HTML doc in my app's Path. I want to launch IExplorer to open it from my program. How do you do this if you don't know where IExplorer is installed?
|
|
|
|
|
You don't have to know. If you use ShellExecute indicating only the file to open, the system will find automatically the appropriate program (IE in your case) to use.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have files with the format:
number, "words", "words", "words", numbers
number, "words", "words", "words", numbers
etc...
I need to read each individual thing( number or "words") in between the commas. I originally checked each caracter to see if it was a comma. If it wasn't I added it to a string then got the next character. If it was a comma then I have my the thing between the commas. This arose two problems. (1)I can't get spaces because I'm reading the file using ifstream. (2)There can be commas in "words" thus ending the string before I read the complete string.
My solution(I dont like it): Because all "words" are surrounded in quotes I could check to find if it has reached the real comma, which i think would add a lot more code But this still doesn't fix the spaces problem. Should I drop the ifstream and use another file reading meathod( I don't know of any)?
[edit]
Oh yeah, the number does not need to be read as a number, it can be read as a string/char.
-Raffi
|
|
|
|
|
Use a tokenizer like <a href="http://boost.org/libs/tokenizer/index.htm">boost:tokenizer</a> . It seems a little overwhelming at first, but comes equipped with a predefined setting for exactly the kind of thing you want to do (check <a href="http://boost.org/libs/tokenizer/escaped_list_separator.htm">escaped_list_separator</a> .)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
iostreams is made for this.
ifstream f ("c:\\myfile.txt");
int n;
string a, b, c;
f >> n >> "," >> a >> "," >> b >> "," >> c;
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I think iostream s won't handle strings enclosed in quotes.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Oh. I don't know about that, but I took the quotes to mean 'this is a string', not 'this is a string in quotes'
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Even assuming the format is very well behaved, iostream s won't work. Consider for instance:
5, "hello", "my", "friends", 10 The first "word" read would be "hello", (comma included), as it is only white space that will stop the stream reading a token.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot.
-Raffi
|
|
|
|
|
Hi every one,
I meet a trouble.
When i installed my applicaiton on a clean win2k. It terminated every time when it execute:
"pws->Create(wsName, UserName,"");" ,
pws is a CDaoWorkspace object.
But after I installed the "Application Performance Explorer" in "Visual Stutio Enterprise tools" on this platform, then My application works well.
What is the different after I install the tool?
What should I do in my installation?
|
|
|
|
|
You got a new set of dlls. One or more of them was different. If you want to move this program to other machines, you will need to find out which one. Use the DEPENDS.EXE program that ships with Visual Studio to get a list of the dlls your program uses. Then look at the versions and dates. Compare them with what is on a "clean" system. You will see a differnece.
Hope the helps,
Bill
|
|
|
|
|
I'm created MDI app without Doc/View suppot.
The name of MDIChild window stored in string table resourse "\nTitle\n".
When I open child wnd, the title of app window is "App - Title" and when I maximise child window "App - Title - [Title]", how can I remove one "Title" from window title?
Anything that can go wrong will go wrong.
|
|
|
|
|
Remove the FWS_ADDTOTITLE style
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Pleas help! I know nothing about Databases
I have an MFC Dialog app that connects to a Access database. I found some great code here www.codeproject.com/database/readdb.asp and this works fine but it only shows how to read from a database. I need to send data to the database from my dialog app as well as read. If anyone knows how to do this using the same structure as in this demo I would be really really grateful!
Thanks,
Alan
|
|
|
|
|
How about this article?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello all,
does anyone have any experience with MS Flex Grid?
I want a simple, MS based, lightweight grid control that allows me to:
- display tabular data
- sort (numerical, dates, string)
- dispaly boolean values (checkbox)
- edit the data
- Show cell focus selection
There is a lot of great information on how to customize the standard MS
list control, but was wondering if MS Flex Grid can be used instead.
If someone knows about a good documentation, please let me know.
thanks
|
|
|
|
|
With the exception of the checkbox, MSFlexGrid will do all of those things. It might even do the checkbox, I've never tried it.
Hope this helps,
Bill
|
|
|
|
|
Maybe a simple question for the most of you...
How can I force to open a menu in a menubar without using the mouse?
I´ve tried this...
RECT rect;
int nCnt = 0;
::GetMenuItemRect(hWnd,hMenu,nCnt,&rect);
::SendMessage(hWnd,
WM_LBUTTONDOWN,
(WPARAM)MK_LBUTTON,
MAKELPARAM(LOWORD(rect.left),HIWORD(rect.top)));
This should open the very first menu in the menubar (typically "File" menu), but it doesn´t work...
Any ideas?
Amar
|
|
|
|
|
You should look up the TrackPopupMenu API call.
Regards
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|