|
Is there a way i can allocate _T("Anton") Into a dynamic memory ? because my code is all mixed up. (I allocate the string using both methods).
|
|
|
|
|
HAHAHA_NEXT wrote:
Is there a way i can allocate _T("Anton") Into a dynamic memory ?
This does not quite make sense, but I think what you want is:
TCHAR *p = new TCHAR[6];
_tcscpy(p, _T("Anton"));
...
delete [] p;
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Ths. It is exactly what i needed. The reason for this kind of weird stuff is because i can allocate the same string 2 ways:
the first is
p = "Anton"
and the second is
<br />
p = new TCHAR[6];<br />
_stprintf(p, ....)<br />
This will avoid me having different variable and one clean delete statement .
|
|
|
|
|
HAHAHA_NEXT wrote:
...
delete ptszVersionInfo; //Executes OK
ptszVersionInfo = _T("Anton"); //Executes OK
delete ptszVersionInfo;
Two problems:
1) You are using ptszVersionInfo after you've done a delete on it.
2) You are doing a second delete on a ptr that you've already done a delete on.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I have a derived Dialog class - CGeneralStatus that has a CString variable. If I set the string before I create the CGeneralStatus dialog it is displayed OK. When I set this string to different value the value in the window does not get changed. Even if I close and reopen the dialog window the value does not change.
Any input is greatly appreciated !
------------------------------------------------------------------------
Application code:
void CFV3TaskMonApp::OnGeneralstatus()
{
if(IsShowingGeneral())
{
HideGeneral();
}
else
{
ShowGeneral(m_pMainWnd->GetActiveWindow());
}
}
void CFV3TaskMonApp::ShowGeneral(CWnd* parent)
{
if (!::IsWindow(*m_generalStatus))
{
m_generalStatus->Create(IDD_GeneralStatus, parent);
}
m_generalStatus->GeneralChanged(); // update the string
m_generalStatus->ShowWindow(1);
}
Code snippet to update the string value before calling ShowWindow(1):
void CGeneralStatus::GeneralChanged()
{
CString out;
out.Format("%d",m_app->m_numConnections);
m_connAttempts = out;
if (::IsWindow(this->GetSafeHwnd()))
{
::PostMessage(this->GetSafeHwnd(),UWM_STATUS_UPDATEGENERAL,0,0);
}
}
|
|
|
|
|
glweid wrote:
When I set this string to different value the value in the window does not get changed.
Even though you've assigned a value to a CString variable, you did not indicate how it was being displayed. Assuming it was an edit or static control, you simply need an appropriate control variable in the dialog's declaration (e.g., CEdit m_editnumConnections ). When it comes time to display the value, simply call m_editnumConnections.SetWindowText() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
My Dialog box only has the string variable (edit control - read only) box displayed, how do you declare a CEdit variable associated with that ?
I added a CEdit m_editnumCOnnections compiled it and passed the new string value to m_editnumConnections.SetWindowText() and it cores not finding a main window handle.
Thanks !
-----------
Code snip
// Dialog Data
//{{AFX_DATA(GeneralStatus)
enum { IDD = IDD_GeneralStatus };
CString m_connAttempts;
//}}AFX_DATA
|
|
|
|
|
Anonymous wrote:
how do you declare a CEdit variable associated with that ?
ClassWizard.
Anonymous wrote:
...and it cores not finding a main window handle
What does "cores" mean in this context? Did you add the appropriate entry to DoDataExchange() ? This is something that ClassWizard would do for you.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I want to suspent my display using a shortcut... no matter if vc++ or not.
Since I've never worked with power management I don't know how.
Any suggestions?
Thx
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
I want to suspent my display using a shortcut...
I don't quite understand what this means.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Have you looked at the Power Management API functions. eg. SetSystemPowerState() Should do the trick.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
thx
(I'm sorry for the wrong spelling of suspend )
Don't try it, just do it!
|
|
|
|
|
How do you stop an SDI application window from being resized?
Thanks
|
|
|
|
|
I think removing the client edge style will do the trick.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Thanks, that worked, but now I have another couple of problems.
First of all I have a status bar and I cannot get rid of the gripper on that.
Secondly there is now a 1 pixel wide transparent gap around the view (where I assume the thick border would have been)
You can see what I mean at http://a.domaindlx.com/sschilachi/snooker.JPG[^]
Thanks
|
|
|
|
|
humm, sorry cant help you with that prob.. post that porblem as seperate question may be someone else will help you.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
one way is to override OnGetMinMaxInfo(). In it, assign values to ptMinTrackSize and ptMaxTrackSize of the lpMMI variable. If the values are the same, the window will not be resizeable, although the arrow still changes to indicate that it can.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yet another way is to make a handler for WM_NCHITTEST in the app's mainframe class. You can "fool" by returning HT_CLIENT values for those on the edges. You can also override CStatusBar and do the same there. I have done this and it works well.
a two cent stamp short of going postal.
|
|
|
|
|
Does anyone know how to change the tab control color on the propertysheet? Overwrite CPropertySheet::OnCtlColor(...) doesn't quite work
|
|
|
|
|
Unless it is part of your requirements (which I would then still question), don't do it programmatically. Change it on the Appearance tab of the Display Properties dialog.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
One possiblity is that You need to custom draw the tabcontrol that is associated with the the propertysheet..
there are few samples here in CodeProject that exactly does that.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
ive been working on some simulation code, what i have written basically what it does it creates a Vector and fills it with random DOUBLE numbers from two different sources untill maz_size reached.. what im stuck is i want to go thorugh each element in the vector..prob using an iterator such as input_iterator i think?
so the vector is such..
[number_from_first_source, number_from_secondSource, number from_first source...etc etc]
so every odd element is form source1 and every even element is from source 2..
now i want to go thorugh each element with specific iterator value..example lets say 20ms i.e. 0.002..quite small value. the random numbers are all seeded values. so how owul di go through the vector with this small iterator value.
i will paste the written code.
]#include <iostream><br />
#include <vector><br />
#include <stdlib><br />
#include <time><br />
#include <numeric><br />
#include <algorithm><br />
#include "exponentialgenerator.h"<br />
<br />
using namespace std;<br />
<br />
ExponentialGenerator one = 1.41;<br />
ExponentialGenerator two = 1.71;<br />
<br />
double nextNumber = reinterpret_cast<double>one.generate());<br />
double nextNumber2 = reinterpret_cast<double>two.generate());<br />
int counter = 0;<br />
<br />
void fillVectorToSum(vector<double>& v, double sum)<br />
{<br />
<br />
int total = 0;<br />
do {<br />
if (counter++ % 2){<br />
v.push_back(nextNumber);<br />
total += nextNumber;<br />
nextNumber = one.generate();<br />
}<br />
else {<br />
v.push_back(nextNumber2);<br />
total += nextNumber2;<br />
nextNumber2 = two.generate();<br />
}<br />
<br />
} while(total+nextNumber+nextNumber2 <= sum);<br />
if(total < sum)<br />
v.push_back(sum-total);<br />
}<br />
<br />
int main()<br />
{<br />
<br />
srand((unsigned) time(NULL));<br />
vector<double> v;<br />
fillVectorToSum(v, 30);<br />
<br />
cout << "Number of elements: " << v.size() << "\nTotal: "<br />
<< accumulate(v.begin(), v.end(), 0) << endl;<br />
copy(v.begin(), v.end(), ostream_iterator<double> (cout," "));<br />
<br />
}
the exponentialGenerator.h file i use jus to generate numbers if your wondering....
anyway any input to this problem would be appreciated.
|
|
|
|
|
What is the problem? Your code seems valid. Are you having output problem like formatting?
Kuphryn
|
|
|
|
|
the code is correct..but i want to go thorugh every element in vector because my silumation will go though each nunmber at 20ms at time chunks and will alow me to 'do stuff' with it..basically i want to know how 2 create a iterator to do this..
you see it will go to the firts number and say its 2 and the iterator is 0.002..s it will keep going thorug it until it reaches end of number ..when it gioes to the second number..something happens..but i dont know how to do this part i.e going thrugh the numbers with this small itertaor value..if u know what i mean.
|
|
|
|
|
vector::iterator it;
for (it = v.begin(); it != v.end(); ++it)
{
}
Ant.
|
|
|
|