|
AnsSum.Format(_T("%d"), Ans);
Cool, it looks like I was on the right track when I was trying to help, just haven't dealt with UNICODE before. I'll have to look into the tchar thing.
Brad Jennings
"if the golden arches shut shop, where else are the VB people going to get work." - Colin Davies
|
|
|
|
|
I used the _T macro, the "correct" way would be to use L("%d") but with _T the code will work for UNICODE and char strings, just check out the MSDN for
"Using Generic-Text Mappings"
"Data Type Mappings"
i.e look for _T in the index
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
hey, I was looking at the tutorial to show fonts in a combo box(http://www.codeproject.com/combobox/fontcombo.asp?forumid=3520&app=50#xxxx). I'm trying to implement it into my program but i'm having trouble.
Keep in mind I'm new to MFC.
It says: "Add a member of type CFontPreviewCombo to your dialog and attach it to your control."
How do I do this? I'm not sure what the member part means. Thanks for any help.
|
|
|
|
|
hello experts,
I created a TimerThread class that derive from CWinThread,
class TimerThread: public CWinThread
{
public:
TimerThread();
SYSTEMTIME* start_time;
SYSTEMTIME* end_time;
VOID SetStartTime(SYSTEMTIME*);
VOID CopyTime(SYSTEMTIME*, SYSTEMTIME*);
};
and I have a global TimeThread* timerThread;
timerThread=AfxBeginThread(RUNTIME_CLASS(TimerThread));
I got the following error, i don't really understand it...
thanks for the help.
C:\sampleC++\dlg\dlgDlg.cpp(130) : error C2039: 'classTimerThread' : is not a member of 'TimerThread'
c:\samplec++\dlg\timerthread.h(2) : see declaration of 'TimerThread'
C:\sampleC++\dlg\dlgDlg.cpp(130) : error C2065: 'classTimerThread' : undeclared identifier
|
|
|
|
|
In your code "classTimerThread" is one world. What is it and where is it declared?
Kuphryn
|
|
|
|
|
sorry the error was thrown at this line:
timerThread=AfxBeginThread(RUNTIME_CLASS(TimerThread));
so it seems RUNTIME_CLASS() returned a classTimerThread or something.. I don't understand..
thanks for the help
|
|
|
|
|
From the MSDN: You must derive your class fromCObject and use the DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC, the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE, or the DECLARE_SERIAL and IMPLEMENT_SERIAL macros.
Software Zen: delete this;
|
|
|
|
|
I was looking at a tutorial here on codeproject and wasn't to sure about how to include the control into my own project. I figured if I post here instead of on the page for the project I may get more responses or someone who has done it. here is the URL
http://www.codeproject.com/richedit/AutocomplectionCtrl.asp
I wanted to put it in a SDI app. Should I just inherit the CRichEditView class? I'm kind of confused on how to incorporate it. Any examples or help would be greatly appreciated! Thank you
paully
|
|
|
|
|
I Tried To Make a 'replacement' for making Dialog Classe Based On Anthor Class instead Of CDialog ,
Actully I didnt Figure Out Howit works .
Can Anyone refer Me A Tutorial Or Explain it To Me ?
Thanks in Advanced
|
|
|
|
|
hi guys, I used appWizard to created a dialog that has a dropdown combobox on it, it's id is DROPDOWNHRSFN, my question is that, inside of its event handler code, how would I be able to obtain a reference of the dropdown combobox? I would like to get the item that the user selects from the combobox. how would I do that? And How would I initialize this combobox with my custom data?
thank you so much
void CDlgDlg::OnDropdownHrsfn()
{
MessageBox("drop down","drop down",MB_OK);
// TODO: Add your control notification handler code here
}
|
|
|
|
|
|
|
As the sig says, Im new to this entire game! Im not only learning VC++, but the IDE to boot! Gosh.. Gimme some Tylenol!!
Ive got a string variable, Number1, I want to convert it Long, but the linker give the message:
error C2664: 'strtol' : cannot convert parameter 1 from 'class CString' to 'const char *'
Heres the code snippit:
===========================================================
GetDlgItemText(IDC_EDIT1, Number1);
GetDlgItemText(IDC_EDIT2, Number2);
CString TmpTxt = "The numbers are " + Number1 + " and " + Number2;
MessageBox( TmpTxt, _T("Error"), MB_ICONINFORMATION | MB_OK);
// Everything above works fine, below is conversion
// which wont work.
long Ans;
Ans = strtol(Number1, NULL, 10);
===========================================================
This is a stupid newbie project, enter two numbers in two Edit Boxes, convert the text var to a long var, add the two, convert it back to text and give a message box with the sum of the two.
I have the Member Variable assigned to IDC_EDIT1 as CString using Number1, and 2 respectively.
I am using eVC++ 3.0 for WinCE.
Any help, thanks much in advance!
This *aint* VB, dats fur sure!
PS
Please reply as if I were a total idiot, becaue I am!
Andrew
New to VC++ programming, working hard to learn.
|
|
|
|
|
The raw CString is not a character string (as you can see.)
PocketBlast wrote:
long Ans;
Ans = strtol(Number1, NULL, 10);
Try
Ans = strtol((LPCSTR)Number1, NULL, 10);
This gives you a pointer to the character data.
"I will find a new sig someday."
|
|
|
|
|
You're using the wrong function. strtol() is only for ANSI strings. Since WinCE is a Unicode OS, use wcstol() instead, which is the Unicode version.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello,
I'm using COleDateTime to parse a date and time field from an
input file. First I reorder the input into a string s of the form: "8:30:00 Jan. 25, 1996", and convert it using:
COleDateTime t;
t.ParseDateTime(s, LOCALE_NOUSEROVERRIDE);
This works, but fails on certain dates since ParseDateTime apparently uses
the locale of my country. Now in my case the input dates are always in US format: Jan, Feb, Mar, Apr, .....Oct, Nov, Dec, so I want to force
ParseDateTime to use a US format (i.e. English only).
How do I do that ?????????
I've tried to use the locale code for English_United_States (0x0409),
but it didn't work. What am I doing wrong ??
Please help !
Best Regards,
-Kasper
|
|
|
|
|
Did you try the 3rd parameter of COleDateTime::ParseDateTime?
|
|
|
|
|
No, I did not ! I now use:
t.ParseDateTime(s, LOCALE_NOUSEROVERRIDE, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ) );
and it works very well.
Thanks, man.
- Kasper
|
|
|
|
|
Hello everyone, I have this XML document and I need to store the content in a C/C++ structure. So far I can use MSXML to load the document and display it but how can I get it into C/C++ struct. I'm completely new to C/C++, can anyone help me to create a C/C++ struct (or linked list) to hold these data and also how to get the XML into the structure created. Many thanks!
<contact>
<personal>
<name>John Moss</name>
<age>28</age>
<house_number>8</house_number>
<street>Polygon Road</street>
<town>London</town>
<country>UK</country>
</personal>
<sport>
<style>Karate</style>
<belt>Second degree black belt</belt>
<champion>1992 1994 1995 1996</champion>
</sport>
</contact>
|
|
|
|
|
I am trying to build a simple linked list and i keep getting the following error: "error C2146: syntax error : missing ';' before identifier 'server'"
here is my code and if anybody can figure it out PLEASE let me know.
#include <fstream>
#include <iostream>
#include <iomanip>
#include <list>
using namespace std;
class server // Actual Data the serverNodes will point to
{
private:
int S_ID;
int Speed;
public:
server(); //Contructor aka (
~server();
};
class request
{
private:
int R_ID;
int Arr_t;
int cpuT;
public:
request();
~request();
};
class serverNode
{
public:
server *entry; //pointer to server object (aka my data)
serverNode *next; //pointer to my next node
serverNode (server *);
~serverNode();
};
serverNode::serverNode( server *p)
{
entry = p;
next = NULL;
}
class LinkedList //list will be responsible for adding,removing etc.
{
private:
serverNode *front; // pointer to the front of my list
serverNode *rear; // pointer to the rear of my list
public:
LinkedList();
~LinkedList();
void insert( server *); //function will insert server data to rear of list
server* remove(void);
server* dis();
};
LinkedList::LinkedList(){front=rear=NULL;}
LinkedList::LinkedList()
server *Linkedlist::dis()
{
front->entry;
}
LinkedList::insert(server *item) //This fucntion will insert next data from the rear
if(rear != NULL)
{
rear->next= new serverNode (item);
rear= rear->next;
}
else
front=rear= new serverNode(item);
}
server *LinkedList::remove(void)
{
server *ret;
if(isEmpty()==false)
{
ret=front->entry;
servernode *tobe_removed = front;
front = front->next;
delete tobe_removed;
if(front==NULL) // if list is becoming an empty list
rear=NULL
}
return ret;
}
int main()
{
int user_in;
cout <<"Welcome to the Washington Heights server system where you network may or may not work\n";
cout << "How many servers you want us to attempt to work with?\n";
cin >> user_in;
return 0;
}
|
|
|
|
|
It would be helpful to actually show the line where compiler stops. I am guessing here :
Sal R. wrote:
LinkedList::LinkedList(){front=rear=NULL;}
LinkedList::LinkedList() //-----> What is it?
server *Linkedlist::dis()
{
front->entry;
}
You have 2(!!!!!) default constructors for LinkedList AND the second one does not have body or terminating ';'
|
|
|
|
|
What would be the best way to create and write into an LPSTREAM
the contents of a CString?
|
|
|
|
|
|
if you want to save the string into a stream:
write the length first, the n the data bytes.
If ANSI/UNICODE might be an issue, either write a "tag" which type is used, or always save as unicode.
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I have some terrible problem
I use following code, but buttons and toolbars sometimes flick. To solve flick's problem with Line/Rectangle/etc. Painting i use m_Context, but this causes another problem ;_(
After of the calling BitBlt function, Buttons and Toolbars repaint.
May be i need to paint buttons to m_Context, but how?
void CMy123Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
CRect button;
m_OK.GetWindowRect(&button);
CRect rect;
m_Frame.GetWindowRect(&rect);
//int Width = rect.Width();
//int Height = rect.Height();
int Width = 1000;
int Height = 1000;
m_Context.BitBlt(0, 0, Width, Height, &m_Context,0,0,WHITENESS);
m_Context.LineTo(300,600);
m_Context.LineTo(0,200);
m_Context.SetTextColor(0);
m_Context.DrawText("SSDSDSDSDJKLHklhljk", CRect(200,200,400,400), NULL);
m_Context.TextOut(500,100,m_str);
dc.BitBlt(0,0, Width, Height, &m_Context,0,0,SRCCOPY);
//CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy123Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int CMy123Dlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CDC *Canvas=GetDC();
m_Context.CreateCompatibleDC(Canvas);
m_Bitmap.CreateCompatibleBitmap(Canvas,1000,1000);
m_Context.SelectObject(&m_Bitmap);
ReleaseDC(Canvas);
m_i=1;
SetTimer(1,7,NULL);
return 0;
}
void CMy123Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Invalidate();
m_i++;
itoa(m_i,m_str,10);
CDialog::OnTimer(nIDEvent);
}
BOOL CMy123Dlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
//return CDialog::OnEraseBkgnd(pDC);
return 0;
}
|
|
|
|
|