|
Hi all,
I posted this a couple days ago but didn't get any response. Thought i would try to post it again and see if someone could help.
Wanted to know if it is possible to both pad a hex numbers with leading 0's and also format the width of the message.
I have a string and i just concat a hex number to it. I just want to space out the numbers so that they will line up with the next string added, so that it has the look of a table.
Right now i am padding the hex number like this:
int myString = 10005;
int myString2 = 20003;
testStr.Format("%03X" , myString);
Str += testStr;
testStr.Format("%03X" , myString2);
Str += testStr;
Listbox.AddString(Str);
I know if i take away the 0, then it will set the width, but i need to do both. CAN THIS BE DONE?
thanks in advance.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
NewHSKid wrote:
Wanted to know if it is possible to both pad a hex numbers with leading 0's and also format the width of the message.
Sure: You know the width of your column, the length of your hex number, and the difference of both is the number of leading '0' you have to prepend.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
You could do it in two stages, format the hex value, then take that as further input to another Format call, using %8.8s (pad on right) or %-8.8s (pad on left) as the format string second time around
eg
testStr1.Format("%03X",myString);
testStr2.Format("%03X",myString2);
Str.Format("%10.10s%10.10s",testStr1,testStr2);
Steve S
I was 15 once. It was a long time ago.
Today, it's 22 years since I started working full-time in IT.
|
|
|
|
|
and, (haven't used Format or printf for a while...) you can specify the field width as an argument itself, like this;
testStr.Format("%0*X", n, myString)
where n is the number of digits you want.
Steve S
|
|
|
|
|
How can I use vector.h in an MFC app?
class_a.cpp:
<br />
#include "stdafx.h"<br />
#include "class_b.h"<br />
class_b.h:
<br />
#include "vector"<br />
class_b.cpp:
<br />
#include "stdafx.h><br />
#include "class_b.h"<br />
There's no code yet.
Compiling class_b.cpp is no problem.
But compiling class_a results in a whole bunch of compiler errors (inside new.h, memory.h, ...). I think it has something to do with namespaces, but I'm not sure. I'm not declaring nor using namespaces of my own. Could also be an debug/release prob.
These are (part of) the errors:
<br />
vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'<br />
vc98\include\new(35) : error C2091: function returns function<br />
vc98\include\new(35) : error C2809: 'operator new' has no formal parameters<br />
vc98\include\new(36) : error C2061: syntax error : identifier 'THIS_FILE'<br />
vc98\include\new(37) : error C2091: function returns function<br />
vc98\include\new(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl operator new(void))(unsigned int)'<br />
vc98\include\new(35) : see declaration of 'new'<br />
...
What do I have to do?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
hi,
Add code below in in stdafx.h
include <vector>
using namespace std;
This will do.
Cheers
Anand
The chosen One
|
|
|
|
|
You might want to make sure the #include >vector< appears before the block that reads
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
in all your files. One way to do this would be to put the #include inside stdafx.h instead.
Steve S
|
|
|
|
|
I've already tried to put the include everywhere, above, under, in another file, ... It didn't work.
I've tried it once again, and guess what...
tnx m8.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Zizilamoroso wrote:
#include "stdafx.h>
Is the mixing of '"' and '>' a typo?
There is nothing more in your files than what you wrote? Then you probably need to add
class_a.cpp:<br />
#include "class_a.h"
Does it help?
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Hi All
How can I design the form in vc++ that should appear like a form which pops up when we click at office assistance help in MS Word.
Thanks
|
|
|
|
|
Just a dialog box but to have some background invisible.
There are some articles in codeproject which explain this.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
These assistant are called MSAgent
And there is complete SDK Available for programming these agents,
one can download this SDK from microsoft Site.
There are many third party characters available as well.
Microsoft also provide MsAgent editor , using which one can create its own characters.
Atif Mushtaq
No Worries
|
|
|
|
|
|
Thanks for helping me
If u donot mind go to the MSWord Help and select office assistant,u will find office assistance image character
appear and then click and u will see form appear on the screen(If do searching). I want like that form and button flushing.
Thanks
|
|
|
|
|
there is a CCheckListBox, there is a CDragListBox, but how to use functions
of both classes?
thanks
|
|
|
|
|
I would like to make my program to fit into paper
when printing out. I know we should deal with that
with this function but I am not sure about parameter
Does anyone know what to put?
BITMAPINFOHEADER *pBMI = (BITMAPINFOHEADER*)(LPVOID)lock;
int nColors = 0;
if( pBMI->biBitCount <= 8 )
nColors = ( 1<< pBMI->biBitCount );
if( b_PrintFit )
{
::StretchDIBits( pDC->GetSafeHdc( ),
pInfo->m_rectDraw.left,
pInfo->m_rectDraw.top,
pBMI->biWidth,
pBMI->biHeight,
0,
0,
pBMI->biWidth,
pBMI->biHeight,
(LPBYTE)pBMI + (pBMI->biSize + nColors * sizeof(RGBQUAD)),
(BITMAPINFO*)pBMI,
DIB_RGB_COLORS,
SRCCOPY);
Thanks
shin
|
|
|
|
|
10th parameter of StretchDIBits should be a pointer to a buffer containing RGB data of bitmap you want to print.
For eg.
CBitmap bmp;
bmp.LoadBitmap(IDB_SOMEBITMAP);
BITMAP bm;
bmp.GetBitmap(&bm);
bm.bmBits is the pointer you need.
Other parameters may be right or wrong cause I dont know what they mean in your program.
By the way, for printing a bitmap you should to create a printer DC and to calculate destination rectangle with paper resolution.
For more info see MSDN!
|
|
|
|
|
recently, i found there is a useful feature in HyperSnap-DX 5, that is capturing the whole scrolled window content into a big bitmap, and I think it is very interesting and try to impliment it in VC,but i failed.I have tried to use ScrollWindowEx, WM_VSCROLL and others, does anynone has any idea on the problem?
Best regard
|
|
|
|
|
|
Hi all,
I've created a MFC extention dll project. in the stdafx.h file i've wrote:
#undef _GUI_LIB_EXPORT_
#ifdef _EXPORT_GUI_LIB_
#define _GUI_LIB_EXPORT_ __declspec(dllexport)
#else
#define _GUI_LIB_EXPORT_ __declspec(dllimport)
#endif
i have 2 exported classes, 1 is a dialog, the other one is a button:
1) class _GUI_LIB_EXPORT_ CMyDlg : public CDialog
2) class _GUI_LIB_EXPORT_ CMyBtn : public CButton
i use an MFC exe project to test my dll.
in the stdafx.h i also write :
#undef _GUI_LIB_EXPORT_
#ifdef _EXPORT_GUI_LIB_
#define _GUI_LIB_EXPORT_ __declspec(dllexport)
#else
#define _GUI_LIB_EXPORT_ __declspec(dllimport)
#endif
when i compile the exe project (that uses the exported dialog and button classes), it seams to recognize the dialog exported class (CMyDlg) but for the CMyBtn class i get the warning C4273 - inconsistent dll linkage. dllexport assumed.
can any1 help???
i am desparate here..
thanks in advanced,
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
|
warning C4273 - inconsistent dll linkage. dllexport assumed.
Isn't the class to be dllexport is what is you want? So, it is correct then. Unless you are importing functions from DLLs.
Why use the macro? Just put in like this
class __declspec(dllexport) CMyDlg : public CDialog<br />
{<br />
...
why making yourself confuse?
hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thanks man!
That did the trick........
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
glad it helps.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
remove the stuff you wrote in the stdafx.h. In your dll project place "_EXPORT_GUI_LIB_" in the preprocessor definitions (project settings). This way the classes will be exported when you have defined "_EXPORT_GUI_LIB_" and imported if not defined (as in your client project). Hope this explains it a bit.
Er zit een korstje op mijn aars.
|
|
|
|