|
pla,deg,0.0,130.0,0.0
pitch_stickF,lbs,-3.28,4.4,0.0
roll_stickF,lbs,-13.0,13.0,0.0
yaw_pedal,lbs,-3.87,3.87,0.0
spbrk_pos,retract.hold.extend,-1.0,1.0,0.0
STOP,1
This is just a test file. The actual file has around 500 lines.
sj
|
|
|
|
|
This is not the recommended way to do what you are doing, but I just wanted to show you an alternative.
struct TSimSignal
{
double Min;
double Max;
double Value;
char Name[32];
char Unit[32];
} t[500];
FILE *pFile;
for (int x = 0; ...)
{
sscanf(pFile, "%[^,],%[^,],%f,%f,%f", t[x].Name, t[x].Unit, &(t[x].Min), &(t[x].Max), &(t[x].Value));
}
|
|
|
|
|
Instead of putting "i<sizeof(s.Name)" in your for loop, use "i<sizeof(s.Name)/sizeof(string)". sizeof() gives you the size of the variable/type in bytes , not the number of elements in the array. The size of a string is at least 4 bytes, so your loop will go at least 20 times - 5*sizeof(string). Your memory will therefore be overwritten by any writes after the 5th loop, and you'll end up with rubbish.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thanks Ryan it works great.
Is there anyway that I can read the file and the items read in are chars instead of strings?
You da' man,
Sj
|
|
|
|
|
johnstonsk wrote:
Is there anyway that I can read the file and the items read in are chars instead of strings?
There is, but I don't really think there's a lot of merit in doing so. Using the string functions is safe - it prevents buffer overflows by allocating just the right amount of memory. Trying to allocate memory yourself is just a PITA and can cause all sorts of security errors. I would stick with what you're doing. If it works safely, there's not much point changing it.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I want to paste a icon from resource to a button by using SetIcon(), but neither m_bttnOpen.SetIcon(AfxGetApp()->LoadIcon(IDI_ICON_OPEN));
nor
m_bttnOpen.SetIcon(::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_OPEN)));
can do this.
Why?
And how to do this by the most simple way?
thankx
|
|
|
|
|
olinn wrote:
Why?
Has your button the icon style checked ? (Go in the ressource editor, right click on your button, tab "styles", check "Icon").
olinn wrote:
And how to do this by the most simple way?
This one :
m_bttnOpen.SetIcon(::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_OPEN)));
~RaGE();
|
|
|
|
|
I know that ASCII numbers 27 and 28 represent up and down arrows. Is there a way to get these symbols into a CSTring?
thanks
|
|
|
|
|
CString cUpDown = "\x1B Up and down arrows \x1C";
onwards and upwards...
|
|
|
|
|
Thanks for your reply, but the resulting string just has dark black lines were I was hoping to see arrows.
|
|
|
|
|
That is dependent upon which font you are using to display the text. Look at the CharMap application. Some fonts have corresponding characters for ^ and v, some don't.
onwards and upwards...
|
|
|
|
|
|
Dear everyone,
I create some CEdit box, the height for example is 20.
and the CEdit box is not multi-line.
But the font size is small, for some function, should
set the text content verticle center or bottom in CEdit.
How can i do?
Welcome any suggestion!
Many thks to u!
Best Regards,
Bosicat
Good Luck
|
|
|
|
|
Sorry, you can't centre the text in an edit box. It can't be aligned with the bottom either. Top-only, I'm afraid
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
Thomas George wrote:
Do anyone know of a way to set different background and foreground colors for the text on individual toolbar buttons?
WM_CTLCOLOR?
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
I got a class declared as follows:
class CWordItemList : public CList<CWordItem*,CWordItem*&>{
public:
void AddTail(CWordItemList* pList);
...
};
void CWordItemList::AddTail(CWordItemList *pList)
{
CList<CWordItem*,CWordItem*&>::AddTail(pList);
//the program asserts(ASSERT_VALID) and throws an error
...
}
How should I derive from CList?
|
|
|
|
|
is there a possibility to easy edit a 24bit toolbar in VS.NET?(by editing i mean settind the IDs, rearrange the order,etc..) i cant believe this is not possible, and i have to rearrange, and cut my nice 24 bit toolbar "by hand"
why is there no support for 24bit toolbars??
greets andreas
|
|
|
|
|
Is it possible to subclass a window belonging to another process?
If yes, then how?
|
|
|
|
|
Yes, but only by using a global hook. There is information on MSDN about how to do this.
Basically you set a global hook (usually a WH_CBT hook) from inside a DLL and when the hook function is called by Windows for a particular process, your DLL is loaded into the address space of that process. You can then subclass whichever windows in that process you want. Usually, you set a hook that activates whenever the HCBT_CREATEWND code is passed (a window is created), but if the window is already created, you may never get the opportunity to subclass it.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
You're welcome
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Am not sure, but won't using WH_CALLWNDPROC or WH_CALLWNDPROCRET hooks to obtain the handle of the window or its controls after creation then using SetWindowLong() to set the GWL_WNDPROC property could do the job of subclassing the window after its creation?
|
|
|
|
|
WH_CALLWNDPROC hooks are called from the context of the process that calls SendMessage() , not the one that receives the message. As long as a message is sent by the same process as the one you're wanting to subclass the window in, it should be OK.
These will work, but these hook functions are called for every message sent to every window. They substantially slow down the system and are not recommended unless absolutely necessary.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|