Click here to Skip to main content
15,891,529 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ Question Pin
dmxdmxdmx0525-Nov-04 7:29
dmxdmxdmx0525-Nov-04 7:29 
GeneralRe: C++ Question Pin
John R. Shaw25-Nov-04 7:44
John R. Shaw25-Nov-04 7:44 
GeneralRe: C++ Question Pin
dmxdmxdmx0525-Nov-04 9:18
dmxdmxdmx0525-Nov-04 9:18 
GeneralRe: C++ Question Pin
John R. Shaw25-Nov-04 9:39
John R. Shaw25-Nov-04 9:39 
GeneralMFC Application Installation Problem Pin
Pradeep Samji25-Nov-04 3:50
Pradeep Samji25-Nov-04 3:50 
GeneralRe: MFC Application Installation Problem Pin
Antony M Kancidrowski25-Nov-04 4:08
Antony M Kancidrowski25-Nov-04 4:08 
GeneralRe: MFC Application Installation Problem Pin
david_gilmour25-Nov-04 17:18
david_gilmour25-Nov-04 17:18 
GeneralHelp needed in MFC Pin
Ibana25-Nov-04 3:01
Ibana25-Nov-04 3:01 
Hello,

I have a problem where I want to update two varibales in my View class through a dialog class CModalmodeDlg. When I press the "OK" button in the dialog I want two separate const char * members to be updated.

The first case is when I select a Cstring from a dropdown and sends it to a const char * member (m_Vectorname) in the view class. That works great,but It doesnt work for the secondview member (m_Modefreq). When a try to display m_Modefreq in the view class it gets all corrupted. But it gets it right when I display it in a messagebox through the dialog.

example.

m_Modefreq in messagebox= "45.23 Hz"

m_Modefreq in ViewClass = "^''*´"



Another observation is that when I in the dialogs OnBnClickedOk() set the second variable (m_Modefreq) to always be the same static value it displays it correct in the view.

below is a code snibbet,






[code]

void CModalmodeDlg::OnBnClickedOk()
{

//get the active view
CFrameWnd* wnd = (CFrameWnd*) AfxGetMainWnd();
if(wnd) m_pView = (CVtkSDIView*) wnd->GetActiveView();

//get the selected string from the dropdown.
CString str;
m_DropDown.GetLBText( idx,str);


const TCHAR *ptr;
ptr = str;

//update the first view member const char *m_Vectorname
//works fine
m_pView->m_Vectorname=(LPCTSTR)str;


int idx = m_DropDown2.GetCurSel();
m_pView->m_Modeindex=idx;



//the method ReturnMode returns a string depending on which index is selected
//from the DropDown.

Currentstring =m_pView->ReturnMode(idx);

//Here I want the other const char * member (m_Modefreq) to be updated.
//it prints out the right in a messagebox but as soon as I try to display it in the view //class it gets all corrupted.

m_pView->m_Modefreq=Currentstring.c_str();


[/code]


When I set it to a static value

[code]

like this:
m_pView->m_Modefreq="45.2 Hz" it manage to update it right.

[/code]


I dont really know what to do about this, please letme know if you have any ideas!

Regards Peter
GeneralRe: Help needed in MFC Pin
Niklas L25-Nov-04 3:13
Niklas L25-Nov-04 3:13 
GeneralRe: Help needed in MFC Pin
Joaquín M López Muñoz25-Nov-04 3:21
Joaquín M López Muñoz25-Nov-04 3:21 
GeneralRe: Help needed in MFC Pin
Ibana25-Nov-04 7:23
Ibana25-Nov-04 7:23 
GeneralRe: Help needed in MFC Pin
Joaquín M López Muñoz25-Nov-04 7:31
Joaquín M López Muñoz25-Nov-04 7:31 
GeneralTimer with 1ms(accurate) resolution Pin
ManishSaha25-Nov-04 2:46
ManishSaha25-Nov-04 2:46 
GeneralRe: Timer with 1ms(accurate) resolution Pin
Joaquín M López Muñoz25-Nov-04 2:52
Joaquín M López Muñoz25-Nov-04 2:52 
GeneralReply Joaquín & toxcct Pin
ManishSaha27-Nov-04 0:46
ManishSaha27-Nov-04 0:46 
GeneralRe: Timer with 1ms(accurate) resolution Pin
toxcct25-Nov-04 2:55
toxcct25-Nov-04 2:55 
GeneralGet the number of bytes in the port queue Pin
Cedric Moonen25-Nov-04 2:08
Cedric Moonen25-Nov-04 2:08 
GeneralRe: Get the number of bytes in the port queue Pin
Joaquín M López Muñoz25-Nov-04 2:49
Joaquín M López Muñoz25-Nov-04 2:49 
GeneralRe: Get the number of bytes in the port queue Pin
Cedric Moonen25-Nov-04 2:54
Cedric Moonen25-Nov-04 2:54 
GeneralProblem with Graphics & CEdit scrolling Pin
mfc_surfer25-Nov-04 1:29
mfc_surfer25-Nov-04 1:29 
GeneralRe: Problem with Graphics & CEdit scrolling Pin
John R. Shaw25-Nov-04 6:19
John R. Shaw25-Nov-04 6:19 
GeneralRe: Problem with Graphics & CEdit scrolling Pin
mfc_surfer27-Nov-04 19:11
mfc_surfer27-Nov-04 19:11 
GeneralRe: Problem with Graphics & CEdit scrolling Pin
John R. Shaw28-Nov-04 7:42
John R. Shaw28-Nov-04 7:42 
GeneralRegarding Registry Pin
max_gundam1525-Nov-04 1:08
max_gundam1525-Nov-04 1:08 
GeneralRe: Regarding Registry Pin
shiraztk25-Nov-04 1:21
shiraztk25-Nov-04 1:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.