|
A 4-byte char array can only hold 3 characters, which obviously isn't enough precision for a float. Can't you just send the raw data? sizeof(float) will tell you how many bytes to send/receive.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Mike,
How would I do that, like this? Here is the function:
INT SetDataToSend(LPCSTR lpDataToSend, UINT lenDataToSend);
void Test()
{
float x = 34.23231;
SetDataToSend((LPCTSTR) x, sizeof(x));
}
Ted
|
|
|
|
|
Does SetDataToSend() expect a C-style string? Or just an array of bytes? If it's the latter (which I think it is, since it has a length parameter) then lpDataToSend should really be declared a BYTE* since LPCTSTR means a null-terminated char array. You can then write:
void Test()
{
float x = 34.23231;
SetDataToSend ( (BYTE*) &x, sizeof(float) );
}
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
float f= 3.0; // 4 bytes IEEE floating point
BYTE *p= &f;
Be warned this only works on same platform client/server. For instance, if your client is on Windows while your server runs on Unix you'll have to reverse the 4 bytes top-to-bottom.
And I swallow a small raisin.
|
|
|
|
|
My class contains static const COLORREF m_icon[<font color = red>16</font>][<font color = red>16</font>] var.
How do I point it so I could use the pointer as: pIcon[<font color = red>1</font>][<font color = red>1</font>] (for e.g.)?
I've tried:
static const **pIcon = m_icon ; //Error
static const *pIcon = *m_icon ; //Not an error but doesn't point properly
static const *pIcon[] = m_icon ; //......
Any other ideas? I guess I kinda forget the fundamentals...
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
static const COLORREF (*pIcon)[16];
I think that'll do it. You need to give all array dimensions except the last so the compiler can do the pointer arithmetic correctly.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I am proficient at C++, but am just learning MFC and Visual Studio.NET
In School I a used was a simple text enditor and gcc, but I think it is important to try new approaches.
I prefer to create my classes by hand, but since I am learning how to use Visual Studio.NET I decided to try the IDE to create new classes and add functions and variables. However I keep running into problems.
Problems with Add Function
1)I cannot seem to create constructors.
-I have to create a function then manually remove the return type.
2)I cannot create constant functions.
-I have to create a function then manually add const to the declaration and deffinition.
3)I cannot use default parameters.
-I have to add the function then add the default parameters to the declaration.
4)Once added I cannot delete functions.
-I have to manually remove both declaration and definition.
5)I can only add one function at a time, then the dialog disappears.
- When adding multiple functions I have to select Add Functions over and over again.
Problems with Add Variables
1)Sometimes when I try to add a variable it appears briefly then vanishes.
-I try over and over and it doesn't work. But when I manually add the variable with the exact same access, name and type my program works fine. Then I delete the variable and try to add it using the IDE and again it adds then vanishes.
(btw I use Lvl 4 warnings and treat warnings as errors)
2) Once added I cannot delete variables.
- I have to manuall remove them from the .h and .cpp files.
3) I can only add one variable ata time, then the dialog disappears
- When adding multiple variables I have to select Add Variable over and over again.
I end up having to edit the .h and .cpp files so extensively that I might as well type the whole thing in.
My Questions
1) Am I doing something wrong or do the Add Function/Variable features just suck?
2) Should I just ignore add function and add varibale unless I am working with an MFC generated class? Or should I use them to with all my classes?
3) Does Borlands C++ IDE suffer from the same flaws?
|
|
|
|
|
the IDE wizards/helpers seems to work when beginning working with VC, but as you get more experience, you'll tend to not use them at all.
To answer the questions :
1- the functionnalities suck, use the wizard to add the basics, and use the keyboard and edit the files.
2- Ignore it.
3- don't know about borland, but I would think that it behaves the same way, doing things that they think is a good practice, but not what you want ..
Max.
|
|
|
|
|
I am setting the slider "on" a button on the toolbar in the OnCreate of CMySlider. This makes a very short slider. (I tried cxChar*32, but that didnt change it...). I want a longer slider. How to set slider length?
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
int cxChar = tm.tmAveCharWidth;
int cyChar = tm.tmHeight + tm.tmExternalLeading;
SetButtonInfo (7, ID_SLIDER, TBBS_SEPARATOR, cxChar * 12);
GetItemRect (7, &rect);
rect.bottom = rect.top + (cyChar + 2);
if (!m_wndSlider.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |
TBS_HORZ | TBS_AUTOTICKS |
TBS_BOTTOM,
rect,
this,
ID_SLIDER))
return -1;
|
|
|
|
|
And getting only one. Also cant sem to set length no matter what I do..
int CSlider1::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CToolBar::OnCreate(lpCreateStruct) == -1)
return -1;
if (!LoadToolBar (IDR_TOOLBAR1))
return -1;
CClientDC dc(this);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
int cxChar = tm.tmAveCharWidth;
int cyChar = tm.tmHeight + tm.tmExternalLeading;
CRect rect;
SetButtonInfo (0, ID_SLIDER, TBBS_SEPARATOR, cxChar * 12);
GetItemRect (0, &rect);
rect.bottom = rect.top + (cyChar + 2);
if (!m_Slider1.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |
TBS_HORZ | TBS_AUTOTICKS |
TBS_BOTTOM,
rect,
this,
ID_SLIDER))
return -1;
SetButtonInfo (1, ID_SLIDER2, TBBS_SEPARATOR, cxChar * 12);
GetItemRect (1, &rect);
rect.bottom = rect.top + (cyChar + 2);
if (!m_Slider2.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |
TBS_HORZ | TBS_AUTOTICKS |
TBS_BOTTOM,
rect,
this,
ID_SLIDER2))
return -1;
return 0;
}
and in mainframe:
BOOL CMainFrame::CreateSlider1()
{
if (!m_wndSlider.CreateEx(this, TBSTYLE_FLAT , WS_CHILD | WS_VISIBLE | CBRS_BOTTOM
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED))
return FALSE;
m_wndSlider.LoadToolBar (IDR_TOOLBAR1);
m_wndSlider.SetWindowText(_T("RGB Spinners: From 0 to 255 _&_ Slider 0 to 255"));
m_wndSlider.EnableDocking (CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
DockControlBar(&m_wndSlider);
return TRUE;
}
|
|
|
|
|
Hi, everyone!
Look at the source codes,
--------
/* #define WIN32 */
#ifdef WIN32
#define MORECORE wsbrk
#endif
--------
Such is the comments,
--------
WIN32 (default: undefined)
Define this on MS win (95, nt) platforms to compile in sbrk emulation.
--------
I have two questions,
1. What means WIN32? When the variable "WIN32" becomes
defined? When it is not defined?
2. What means "sbrk" in the comment? What means "wsbrk"?
Btw: the software is written for both Windows and Linux
platforms.
Cheers,
George
|
|
|
|
|
I won't answer what WIN32 means.
As far as I guess, wsbrk is a supposedly cross-platform macro which, when applied on WIN32 with UNICODE switch, becomes wcspbrk(). Whose signature is :
wchar_t *wcspbrk(
const wchar_t *string,
const wchar_t *strCharSet
);
Well in fact this macro could expand to anything other than wcspbrk but the name resembles it!
And I swallow a small raisin.
|
|
|
|
|
Thanks, StephaneRodriguez pal!
Do you mean wsbrk is used for character searching?
In my mind, it is used for memory management.
I have used man in Linux and MSDN in Windows to seek help, I find that sbrk is used for memory management in Linux. So, I think wsbrk is used for windows platform. The letter "w" here means windows. But I am not sure about it. And I also have little knowledge about memory management in low OS level. What is your opinion?
Cheers,
George
|
|
|
|
|
From Unix reference, obviously sbrk does a sort of malloc. So yes wsbrk might well expand to malloc or equivalent when it is on a WIN32 system.
There is no sbrk or wsbrk method available directly on WIN32, at least no result from MSDN search.
And I swallow a small raisin.
|
|
|
|
|
Thanks, StephaneRodriguez pal!
I think the same with you.
Cheers,
George
|
|
|
|
|
I want to install a USB device driver in my program!
A friend of mine tell me use the function "SetupCopyOEMInf",
but I know that this function can't be used on Windows98!
I want my program running on both WindowsNT and Windows98!
Who can give me an example or some advice!
Thanks in advance!
|
|
|
|
|
Hi, everyone!
I have searched the help page for "size_t" but failed
to find the help page and information about "size_t".
Where can I find the help page or information about
"size_t"? Can you paste detailed information about
"size_t".
Thanks.
Cheers,
George
|
|
|
|
|
|
Thanks, Lasse pal!
Your reply helps a great deal!
Have a nice weekend,
George
|
|
|
|
|
size_t isn't Microsoft-specific, it's part of ANSI/ISO standard C. It's defined in <stddef.h> and it's the type returned by the sizeof operator.
|
|
|
|
|
|
|
How about unsigned int?!?
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
Thank, BlackSmith!
I got it!
Cheers,
George
|
|
|
|
|
I'm trying to access XML Web Service using C++ and I've got two
problems.
First, when I try to invoke web service's method from another thread
(not UI thread) I get SOAPCLIENT_INITIALIZE_ERROR error.
Second, when I pass to web service BLOB data which length is greater
than approximately 800KB I get
ERROR_IO_PENDING error (returned by GetLastError).
Is there any way to invoke web service's methods in worker threads and
to pass in BLOBs that are larger
than 800KB (C# client can send about 3MB)?
|
|
|
|