|
No there is not.
The best you can do is to allocate a new buffer, and copy all of the data from the first buffer into the second buffer. Delete the memory from the first buffer, then assign the pointer from the second buffer back to the first.
By the way, the VB method is just more convenient, not more effifient, underneath all of this work is done by VB as well, you just do not have to deal with it.
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!
|
|
|
|
|
short answer to this particular question: use CStringArray. you can resize the array all you want.
not as short answer to this particular question: use std::vector<CString>. vectors are dynamic arrays, so you can resize them at will.
but, short answer to the general question "can i resize an array allocated with 'new'?": no.
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
Ok. This is my code, iøm using the CreateDIalog function so i can use my Resource file to design the app:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
ghInstance = hInstance;
ghWnd = CreateDialog (hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, WndProc);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
but when i run the program, nothing appears.
Thanks all!
|
|
|
|
|
I guess you need to call ShowWindow(SW_SHOW) after create.
|
|
|
|
|
Cool it works now. But i can't move the window now... any ideas?
Thanks
|
|
|
|
|
Ensure that the dialog has a caption bar and your dialog proc is handles standard messages by calling the default handler. Any reason why you're using the Win32 API instead of MFC?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
yes, this is the procedure, i've placed brakepoints in it to make sure it enters it and it does:
BOOL CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return (0L);
}
and the reason why i use it is because i think i have more control over my program, i don't like those embedded things, hope you understand me
|
|
|
|
|
Anonymous wrote:
and the reason why i use it is because i think i have more control over my program,
Imho, it's much easier to build GUIs using MFC. You get a lot of support from the framework.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I agree, but when you can use the Dialog designer with a non-MFC program i think it's better.
|
|
|
|
|
Anonymous wrote:
i think it's better
i've never heard someone using MFC ask why they can't move their dialog...
but, to each his own.
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
My guess is that the move command does not reach the call to DefWindowProc.
If fact, if the command is not handled by your code (ID_FILE_EXIT in this case), then DefWindowProc should be called.
Thus you should add a default in the internal switch that will call DefWindowProc.
But according to MSDN, systems command like SC_MOVE are send as a WM_SYSCOMMAND message so it may be something else...
Philippe Mori
|
|
|
|
|
I already have a default case in my switch statement...:
BOOL CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case IDC_OPENFILE:
OnOpenFile(hWnd);
break;
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
}
break;
case WM_INITDIALOG:
OnInitApp(hWnd);
break;
case WM_DESTROY:
RegSave(hWnd);
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return (0L);
}
i have also made breakpoints so see if the satement is executed, and it is..
|
|
|
|
|
Hey Guys
If i use an instance of a class in a funtion then deallocate it is it deallocated again when the function drops out. I only ask cos i keep getting a close handle again on my file access class at the end of my function even though i have already destructed the instance and haven't created another.
Peter
|
|
|
|
|
if you "new" an object, then the destructor is only called when you "delete" it.
if you allocate the object on the stack, the destructor is called when the object goes out of scope.
one or the other (or you can explicitly call the destructor, but that's something you can't really do without knowing you're doing it)
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
If you store a pointer to class A as member variable in class B, and class B is designed to delete the A object in its own destructor, you should reset the pointer to NULL when you manually delete object A. This will make it clear:
B:: ~B()
{
if (m_ptrA != NULL) {
delete m_ptrA;
}
}
B::someFunction()
{
m_ptrA = new A();
...;
delete m_ptrA;
m_ptrA = NULL;
} /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
No. But if you haven't created your own copy c'tor and assignment operator a HANDLE wrapper class might use the compiler generated versions and then two object might try to release the same resoucrce when they are destructed.
|
|
|
|
|
Hi:
This may be a stupid question.
In a dialog box, a certain function is called when I press 'Add' button. This function adds data to the listbox and then goes through the loop which takes about 15 seconds. The listbox doesn't get repainted until this long procedure is over (in fact, the control disappears from the screen at all during that time).
Is there a way to refresh/repaint the control BEFORE this lengthy loop is called?
Thanks
|
|
|
|
|
UpdateWindow will update the contents. Also, another function for you to be aware of is SetRedraw which allows you to disable drawing for situations where you're doing a lot to the control and don't want the flicker - but instead want a complete redrawing of the control only when finished.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
In addition to Tom's suggestions, you shouldn't be repopulating the entire list box when you add an item. This is a common GUI mistake. Instead, keep the listbox in synch with your data store by simply adding/inserting a single element. This will make your GUI respond faster and appear more professional.
If you must repopulate the list box, show a busy cursor. Use AfxGetApp()->DoWaitCursor() to do this.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi!
You are really taking the things out of context and causing utter confusion to the people who are looking for 'good' suggestions. Please look at a question twice or thrice before posting your suggestion.
Thanks
|
|
|
|
|
Yes, I'm well aware of the original question. What about my suggestion did you find not good or misleading?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I should've read the question the 4th. time. Thanks!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I don't think you will listen the 'real' music even at the n'th time;P
|
|
|
|
|
I have a menu item to exit the application(MDI).
the title on the menu Item is "Exit".
what is the best(safest) way to terminate the application ?
|
|
|
|
|