Tuesday, 31 January 2012

CImageList Add return index skipping fix C++

iIndex = m_ImgList.m_ImageListCopy.Add(&cb16,CLR_NONE );

If the iInex skips e.g. 4 from last image then this means the image is actually 4x larger and needs scaling to 16x16.

Saturday, 28 January 2012

How to convert CString to std::wstring or usigned short * c++

CString str = "Hello World";
 wchar_t buffer[255];
 // convert the text
 mbstowcs(buffer,(LPCSTR)str,str.GetLength()+1);

Wednesday, 25 January 2012

error C2061: syntax error : identifier 'THIS_FILE' c++

To fix this move all your include files above the #ifdef _DEBUG  and using namespace std below. e.g.

#include "stdafx.h"
#include <stdlib.h>
#include <string>
#include <iostream>


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


using namespace std;

Thursday, 19 January 2012

Paper page sizes in points / picas / pixels / inches / mm / cm

Here's a list of paper page sizes:-
This list of the common American and European paper sizes includes the ISO standards, which are used globally. All dimensions are specified in inches, millimeters as well as PostScript points (1/72 inch, always rounded off).
This overview covers:
  • ISO page sizes – The ISO A series is the most frequently used page measurement standard. It includes the DIN A4 format. The ISO B sizes are used for poster printing while ISO C is meant for envelopes. The SRA standard defines press sheet sizes and is used in the printing industry.
  • American paper size dimensions – such as ‘Letter’, ‘Legal’ and the ANSI series.
  • English sheet sizes – with a focus on formats for writing paper and book printing.

ISO A paper sizes

The A-series consists of a logical set of paper sizes that are defined by the ISO 216 standard. The largest size (A0) measures one square meter. The height/width ratio remains constant (1:1.41) for all sizes. This means you get the A1 size by folding an A0 paper in two along its shortest side. Then fold the A1 size in two to get an A2 size paper, and so on… A-sizes are used to define the finished paper size in commercial printing: A4 is for office documents, A5 is for notepads and A6 is for postcards.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
A0
1189
841
46.81
33.11
3370
2384
A1
841
594
33.11
23.39
2384
1684
A2
594
420
23.39
16.54
1684
1190
A3
420
297
16.54
11.69
1190
842
A4
297
210
11.69
8.27
842
595
A5
210
148
8.27
5.83
595
420
A6
148
105
5.83
4.13
420
298
A7
105
74
4.13
2.91
298
209

ISO B paper sizes

The same logic from the A-sizes also applies for the B-series, except here the starting point was the dimension of one of the sides, which starts at 1 meter. B-sizes are often used for posters.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
B0
1414
1000
55.67
39.37
4008
2835
B1
1000
707
39.37
27.83
2835
2004
B2
707
500
27.83
19.69.
2004
1417
B3
500
353
19.69
13.90
1417
1001
B4
353
250
13.90
9.84
1001
709
B5
250
176
9.84
6.93
709
499
B6
176
125
6.93
4.92
499
354
B7
125
88
4.92
3.46
354
249
B8
88
62
3.46
2.44
249
176
B9
62
44
2.44
1.73
176
125
B10
44
31
1.73
1.22
125
88

ISO C paper sizes

C-sizes are used for envelopes to match the A-series paper. I have omitted unrealistic sizes like C0 (imagine an envelope measuring 917 by 1297 millimetres).
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
C2
458
648
18.03
25.51
578
1837
C3
324
458
12.76
18.03
919
578
C4
229
324
9.02
12.76
649
919
C5
162
229
6.38
9.02
459
649
C6
114
162
4.49
6.38
323
459

ISO D paper sizes

I have no idea what D-sizes are used for but the standard is there so it should be mentioned.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
D0
771
1090
30.35
42.91
2186
3090

ISO RA & SRA paper sizes

These oversized papersizes are used by printers. The dimensions in millimetres are rounded to the nearest value.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
SRA0
900
1280
35.43
50.39
2551
3628
SRA1
640
900
25.20
35.43
1814
2551
SRA2
450
640
17.72
25.20
1276
1814
SRA3
320
450
12.59?
17.72
907?
1276
SRA4
225
320
8.86?
12.59?
638?
907?
RA0
860
1220
33.86
48.03
2438
3458
RA1
610
860
24.02
33.86
1729
2438
RA2
430
610
16.93
24.02
1219
1729

American paper sizes

The US and Canada do not use the international standards but instead rely on the paper sizes below. The ANSI standard was added in 1995 to create a set of sizes that are based on shared dimensions. It lacks however the consistent aspect ratio of the ISO A-series.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
Letter (ANSI A)
279.4
215.9
11.00
8.50
792
612
Legal
355.6
215.9
14.00
8.50
1008
612
Ledger (ANSI B)
431.8
279.4
17.00
11.00
1224
792
Tabloid (ANSI B)
279.4
431.8
11.00
17.00
792
1224
Executive
266.7
184.1
10.55
7.25
756
522
ANSIC
432
559
17.00
22.00
1224
1584
ANSID
559
864
22
34
1584
2448
ANSIE
864
1118
34.00
44.00
2448
3168

The below are not available in the -paper parameter.

English paper sizes (writing papers)

The English nowadays use the A-sizes for office and general use. I have no idea whether many of these definitions are still in use today. Imperial and half-imperial still seem to be widely used by artists.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
Foolscap
419
336
16.50
13.25
1188
954
Small Post
469
368
18.50
14.50
1332
1044
Sheet and 1/3 cap
588
336
22.00
13.25
1584
954
Sheet and 1/2 cap
628
336
24.75
13.25
1782
954
Demy
507
394
20.00
15.50
1440
1116
Large Post
533
419
21.00
16.50
1512
1188
Small medium
558
444
22.00
17.50
1584
1260
Medium
584
457
23.00
18.00
1656
1296
Small Royal
609
482
24.00
19.00
1728
1368
Royal
634
507
25.00
20.00
1800
1440
Imperial
761
559
30.00
22.00
2160
1584

UK metric book printing sizes

For books A-sizes often aren’t used because A4 is too large and A5 too small. Metric Royal Octavo and Metric Crown Quarto are 2 frequently used sizes that are more comfortable to hold and read.
Millimeters
Inches
Points
Height
Width
Height
Width
Height
Width
Metric Crown Quarto
246
189
9 11/16
7 7/16
697
536
Metric Crown Octavo
186
123
7 5/16
4 13/16
527
349
Metric Large Crown Quarto
258
201
10 3/16
7 7/8
731
570
Metric Large Crown Octavo
198
129
7 13/16
5 1/16
561
366
Metric Demy Quarto
276
219
10 7/8
8 5/8
782
621
Metric Demy Octavo
216
138
8 1/2
5 7/16
612
391
Metric Royal Quarto
312
237
12 1/4
9 5/16
884
672
Metric Royal Octavo
198
129
7 13/16
5 1/16
561
366

Monday, 16 January 2012

convert doube DATE to CTime c++

DATE dt = spJMessage->GetDate();
SYSTEMTIME st;
COleDateTime d(dt);
d.GetAsSystemTime(st);
CTime tm(st);


CString m_emailDate;
m_emailDate.Format("%.2d/%.2d/%.4d",tm.GetDay(),tm.GetMonth(),tm.GetYear());

Wednesday, 4 January 2012

convert std wstring to std string c++

    BSTR bstr = SysAllocString(strMessage.c_str());
    _bstr_t bstr1(bstr);
    std::string str(bstr1);
    SysFreeString(bstr);