Home > Software engineering >  I use VC2015 C "518 lottery software" you see how level, to highlight the code
I use VC2015 C "518 lottery software" you see how level, to highlight the code

Time:11-19

www.518cj.net

# include "stdafx. H"
# include "resource. H"
# include "bigint. H"
# include "app. H"



/*
Why the layout can be a problem?


*/
LayoutOfRoll_t Tapp: : get_layoutOfRoll ()
{
UiMain_t & amp; UI=m_uiMain;

The RECT rc=UI. Rects [ELE_ROLLAREA];
Int w=rc. Right - rc. Left;
Int h=rc. Bottom - rc. Top;

Wstring longestStr;
WCHAR strSeqno [48]={0};
Seqno2str (1, m_awards [m_pgs iAward]. Quota, strSeqno);
If (UI. Roll_bSeqno) longestStr=strSeqno;
LongestStr +=m_cxrs. LongestCxr;
//the longest and calculation of aspect ratio may be wrong, as a result,
//such as aspect ratio 1:1, similar to the square
Double longestWhr=calc_whr (longestStr c_str ());

Double pctColGap=UI. PctColGap (m_cxrs bPhotoMode, longestWhr);
Double pctRowGap=UI. PctRowGap (m_cxrs. BPhotoMode, m_cxrs photoWhr);

Int maxColNum=m_pgs. NumOfRolling;
If (maxColNum & gt; MAX_COL_NUM)
MaxColNum=MAX_COL_NUM;

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - the largest cell_w, cell_h
LayoutOfRoll_t ly={0};
For (int colNum=1; ColNum & lt;=maxColNum; ColNum++)
{
Int rowNum=m_pgs. NumOfRolling/colNum;
If (m_pgs numOfRolling % colNum!=0)
RowNum++;

Double w1, w2,
If (m_cxrs bPhotoMode & amp; & UI. Roll_bFlnm & amp; & UI. Roll_bFlnmOut)
{
W1=(double) w/(colNum + pctColGap * (colNum - 1));
W2=(double) h/(rowNum + pctRowGap * (rowNum - 1) + UI. PctFlnmAreah () * rowNum) * m_cxrs photoWhr;
}
Else if (! M_cxrs. BPhotoMode)
{
W1=(double) w/(colNum + pctColGap * (colNum - 1));
W2=(double) h/(rowNum + pctRowGap * (rowNum - 1)) * longestWhr;
}
The else
{
W1=(double) w/(colNum + pctColGap * (colNum - 1));
W2=(double) h/(rowNum + pctRowGap * (rowNum - 1)) * m_cxrs photoWhr;
}
/*
W1 w2 which one should be selected, the following don't seem to do

*/
Double cell_w=w1 & gt; W2? W2: w1.
Double cell_h=m_cxrs. BPhotoMode? (cell_w/m_cxrs. PhotoWhr) : (cell_w/longestWhr);

If (cell_w & gt; Ly. Cell_w)
{
Ly. Cell_w=cell_w;
Ly. Cell_h=cell_h;
Ly. ColNum=colNum;
Ly. RowNum=rowNum;
}
Else if (cell_w==ly. Cell_w) {; }
The else break;
}//for

//the code below is the key problem:
//you are calculated according to the a box on the location of the font width to height ratio, it is concluded that the cell, the aspect ratio into wrong what also don't know
//
//according to the cell, and STR + the font, get the net price of the cell, becomes in a normal font or what
//
//
//
//
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//the actual cell_w, cell_h body_lf, flnm_areah, flnm_lf, flnm_lineh
If (m_cxrs. BPhotoMode)
{
If (ly) cell_w & gt; M_cxrs. PhotoSize * MAX_PHOTO_ZOOM | | ly. Cell_h & gt; M_cxrs. PhotoSize * MAX_PHOTO_ZOOM)
{
Double r=ly. Cell_w/(m_cxrs photoSize * MAX_PHOTO_ZOOM);
If (ly) cell_w & lt; Ly. Cell_h) r=ly. Cell_h/(m_cxrs. PhotoSize * MAX_PHOTO_ZOOM);
Ly. Cell_w=ly. Cell_w/r;
Ly. Cell_h=ly. Cell_h/r;
}
If (UI. Roll_bFlnm)
{
Ly. Flnm_areah=ly. Cell_h * UI pctFlnmAreah ();
Ly. Flnm_lf=get_lfOfActl (m_paintMain. MemDc, longestStr c_str (), UI. Roll_font, ly. Cell_w, ly. Flnm_areah, NULL, & amp; Ly. Flnm_lineh);
}
}
The else ly. Body_lf=get_lfOfActl (m_paintMain memDc, longestStr. C_str (), UI. Roll_font, ly. Cell_w, ly. Cell_h, & amp; Ly cell_w, & amp; Ly. Cell_h);

//font beyond the dotted line, calculation of lf time here
//
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
other calculation//why percentage also feel wrong, should be not apply
Ly. ColGap=ly. Cell_w * pctColGap;
Ly. RowGap=ly. Cell_h * pctRowGap;

Double x_remain=w - ly. Cell_w * ly colNum - ly. ColGap * (ly. ColNum - 1);

If (UI. Roll_align==ALIGN_NEAR) ly. Offx=0.0;
Else if (UI) roll_align==ALIGN_CENTER) ly. Offx=x_remain/2.0;
The else ly. Offx=x_remain;

Double y_remain=h - ly. Cell_h * ly rowNum - ly. RowGap * (ly. RowNum - 1);
If (m_cxrs bPhotoMode & amp; & UI. Roll_bFlnm & amp; & UI. Roll_bFlnmOut)
Y_remain -=ly. Flnm_areah * ly. RowNum;

If (UI. Roll_valign==ALIGN_NEAR) ly. Offy=0.0;
Else if (UI) roll_valign==ALIGN_CENTER) ly. Offy=y_remain/2.0;
The else ly. Offy=y_remain;

Return ly;
}


Void Tapp: : hitTest (const the RECT * rects, const BOOL * flagsOfShow, int rectNum, int x, int y, int * which, LONG * type)
{
POINT pt;
Pt. X=x;
Pt. Y=y;
for (int i=0; i {
If (flagsOfShow [I] & amp; & The PtInRect (& amp; Rects [I], pt))
{
* which=I;

The RECT rc=rects [I];
Rc. Left +=ELE_EDGE;
Rc. Bottom=rc. Top + ELE_EDGE;
Rc. Right -=ELE_EDGE;
If (PtInRect (& amp; Rc, pt)) {* type=HIT_T; return; }//top

Rc=rects [I];
Rc. Left=rc. Right - ELE_EDGE;
Rc. Top +=ELE_EDGE;
Rc. Bottom -=ELE_EDGE;
If (PtInRect (& amp; Rc, pt)) {* type=HIT_R; return; }//right

Rc=rects [I];
Rc. Left +=ELE_EDGE;
Rc. Top=rc. Bottom - ELE_EDGE;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related