|
Maximilien wrote: do you keep the parameters and put them in comments
LRESULT MyHandler( WPARAM /*wParam*/, LPARAM /*lParam*/ );
That one usually, but sometimes this one:
Maximilien wrote: remove the parameters :
LRESULT MyHandler( WPARAM , LPARAM );
Maximilien wrote: simply ignore the warning in the projets's settings
I try not to do global warning ignores - I tend to use #pragma warning (disable) when absolutely necessary (usually the warnings which make me feel like saying "well, duh, tell me something I didn't already know" to the compiler).
|
|
|
|
|
Could use overloaded wrapper methods to cope with old/new invocations? e.g. If adding a new parameter for tweaked functionality of a complex legacy method you don't want to mess with - other than the tweak ...
void legacyFunction(int originalParam, bool newFlag)
{
}
void legacyFunction(int originalParam)
{
legacyFunction(originalParam, false);
}
|
|
|
|
|
Maximilien wrote: or remove the parameters :
LRESULT MyHandler( WPARAM , LPARAM );
I tend to go this route.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Maximilien wrote: LRESULT MyHandler( WPARAM /*wParam*/, LPARAM /*lParam*/ );
I use/see this more often.. and some times
Maximilien wrote: LRESULT MyHandler( WPARAM , LPARAM );
Maximilien wrote: or use a macro to mark the parameters as unused ?
I have some times used/seen macro UNREFERENCED_PARAMETER which i think is already defined
So i think you don't need to define a new one..
Well this is just my opinion and the things i came across maintaining applications.
Regards,
Sandip.
|
|
|
|
|
dear sir/madam!
i have created dialog based application in MFC. and created COLORREF Array like this..
p_Cam1_Process_View_Array = new COLORREF*[IMAGE_HEIGHT];
for(int j=0; j<IMAGE_HEIGHT; j++)
p_Cam1_Process_View_Array[j] = new COLORREF[IMAGE_WIDTH];
for(int t_Y=0; t_Y < IMAGE_HEIGHT; t_Y++)
{
for(int t_X=0; t_X < IMAGE_WIDTH; t_X++)
{
p_Cam1_Process_View_Array[t_Y][t_X]=RGB(100,0,12);
}
}
how to display this array in to static Box.
i wrote the below coding but its getting off the application
BOOL CDlg_view_arrayDlg::Fn_Show_Processed_Image()
{
int t_Red, t_Green, t_Blue, t_X=0, t_Y=0, t_K=0;
CString ak;
try
{
CClientDC dc(&m_Processed_Image);
RECT t_Rect;
int t_Width=0, t_Height=0, w=0, h=0, k=0;
BITMAP t_bitmap;
HDC t_hmainmemdc=0;
HBITMAP t_hmainbitmap=0;
int t_Padding=((t_Width*3)%4==0)?0:4-((t_Width*3)%4);
BYTE *t_Byte;
w=t_Width*3+t_Padding;
h=t_Width;
BITMAPINFO *bm;
bm = (BITMAPINFO*) new BYTE[sizeof(BITMAPINFO)];
bm->bmiHeader.biBitCount=24;
bm->bmiHeader.biCompression=BI_RGB;
bm->bmiHeader.biHeight=IMAGE_HEIGHT;
bm->bmiHeader.biPlanes=1;
bm->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bm->bmiHeader.biWidth=IMAGE_WIDTH;
t_Byte = new BYTE[w*h];
GetDIBits(t_hmainmemdc,t_hmainbitmap,0,h,t_Byte,bm,DIB_RGB_COLORS);
k=0;
for(int i=IMAGE_HEIGHT-1; i>0; i--)
{
for(int j=0; j<IMAGE_WIDTH; j++)
{
t_Blue = GetBValue(p_Cam1_Process_View_Array[i][j]);
*(t_Byte+k) = t_Blue;
k++;
t_Green = GetGValue(p_Cam1_Process_View_Array[i][j]);
*(t_Byte+k) = t_Green;
k++;
t_Red = GetRValue(p_Cam1_Process_View_Array[i][j]);
*(t_Byte+k) = t_Red;
k++;
}
k=k+t_Padding;
}
SetDIBitsToDevice(t_hmainmemdc,0,0,t_Width,t_Height,0,0,0,t_Height,t_Byte,bm,DIB_RGB_COLORS);
delete t_Byte;
//To set the scroll position;
BitBlt(dc.m_hDC , 0,0, t_Width, t_Height, t_hmainmemdc,0,0, SRCCOPY);
GetClientRect(&t_Rect);
if (t_Width>(t_Rect.right-t_Rect.left))
{
SetScrollRange(SB_HORZ,0,t_Width-(t_Rect.right-t_Rect.left),TRUE);
}
else
SetScrollRange(SB_HORZ,0,0,TRUE);
if (t_Height>(t_Rect.bottom-t_Rect.top))
{
SetScrollRange(SB_VERT,0,t_Height-(t_Rect.bottom-t_Rect.top),TRUE);
}
else
SetScrollRange(SB_VERT,0,0,TRUE);
CancelDC(dc.m_hDC);
return 0;
}
catch(...)
{
ak.Format("Red %d, Green %d Blue %d", t_Red, t_Green, t_Blue);
MessageBox(ak);
}
}
please let me know as possible.
thanks in advance.
AK
|
|
|
|
|
I honestly advise you to search (in internet) and study some basic bitmap (bmp) management before you code this...
- ns ami -
|
|
|
|
|
Shouldn't the following line(s) of code make Reichman come out in Red ????
RichWindow = GetDlgItem(hwndDlg,IDC_RICHEDIT21);
memset( &cf, 0, sizeof cf );
cf.cbSize = sizeof cf;
cf.dwMask = CFM_COLOR;
cf.crTextColor = RGB(255,0,0);
cr.cpMin = 1;
cr.cpMax = 7;
SendMessage(RichWindow, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
SendMessage(RichWindow, EM_EXSETSEL,0,&cr); // Set the Seelction
Strcpy(&stor_buffer[0],"Reichman is a great guy and a great programmer");
mysettext.flags = ST_DEFAULT;
mysettext.codepage = CP_ACP;
SendMessage(RichWindow,WM_SETTEXT,&mysettext,(LPSTR) &stor_buffer[0]);
|
|
|
|
|
Shouldn't you use WM_SETTEXT first and THEN do the formatting?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
You want EM_SETTEXTEX rather than WM_SETTEXT ...
|
|
|
|
|
Just looked that up ??? thankx
While I was on MSDN I noticed you can DC (Device Context API's) with rich edit
Dont know if thier is confilict with thse two concepts
What If I try TextOut ??????
|
|
|
|
|
how to conver TCHAR to const char*? I searchd a lot...but i didnt get satisfied answer?
|
|
|
|
|
TCHAR is a macro for either char or wchar_t depending on whether UNICODE has been defined.
So which one is it?
«_Superman_»
|
|
|
|
|
|
|
I suppose you need TCHAR * to const char * conversion. Have a look at [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
crazy_sam wrote: I searchd a lot
I don't think so: I provided you with a link to an excellent article where everything is very well explained.
|
|
|
|
|
I am reading some text content from a .TXT file which I want to display in a Dialog control. I am reading the text using the following Code:
CFile *LogFile =new CFile;
LogFile->Open( GlbFileName, CFile::modeRead | CFile::shareDenyNone, NULL );
CArchive Archive(LogFile,CArchive::load);
oLogFileDisp.Serialize(Archive);
Archive.Close();
LogFile->Close();
m_LogfileContent.ResetContent(); //ListBox Control
for(int i=0;i<mLogFileDataArr.GetSize();i++)
{
CString strOneLine;
strOneLine=mLogFileDataArr[i];
m_LogfileContent.AddString(strOneLine); //ListBox Control
}
//ListBox Control
m_LogfileContent.SendMessage(WM_VSCROLL,MAKELPARAM(SB_BOTTOM,0),NULL);
The sample text content is as follows:
16:48:07 ALARM AIC201 FLUE GAS O2 3.00 10.00 20.51 High
16:48:07 ALARM FIC201 AIR MASTER 272.00 1000.00 0.00 Low
16:48:07 ALARM FIC311 PRM AIR MIL-A 26.00 100.00 0.00 Low
16:48:07 ALARM FIC312 PRM AIR MIL-B 26.00 100.00 0.00 Low
16:48:07 ALARM FIC313 PRM AIR MIL-C 26.00 100.00 0.00 Low
16:48:07 ALARM FIC314 PRM AIR MIL-D 26.00 100.00 0.00 Low
16:48:07 ALARM LIC101 CONDSR HOTWEL 600.00 1400.00 -95.84 Low
16:48:07 ALARM LIC102 DEAER STR TNK 1200.00 2800.00 -250.00 Low
16:48:07 ALARM LIC111 LP HTR 1 LVL 80.00 220.00 -50.00 Low
16:48:07 ALARM LIC112 LP HTR 2 LVL 80.00 220.00 -46.20 Low
16:48:07 ALARM LIC113 LP HTR 3 LVL 80.00 220.00 -46.18 Low
The Problem is the allignment of the numerical values are as straight as they appear above. They appear as follows:
16:48:07 ALARM AIC201 FLUE GAS O2 3.00 10.00 20.51 High
16:48:07 ALARM FIC201 AIR MASTER 272.00 000.00 0.00 Low
16:48:07 ALARM FIC311 PRM AIR MIL-A 26.00 100.00 0.00 Low
16:48:07 ALARM FIC312 PRM AIR MIL-B 26.00 100.00 0.00 Low
16:48:07 ALARM FIC313 PRM AIR MIL-C 26.00 100.00 0.00 Low
16:48:07 ALARM FIC314 PRM AIR MIL-D 26.00 100.00 0.00 Low
16:48:07 ALARM LIC101 CONDSR HOTWEL 600.00 1400.00 -95.84 Low
16:48:07 ALARM LIC102 DEAER STR TNK 1200.00 2800.00 -250.00 Low
16:48:07 ALARM LIC111 LP HTR 1 LVL 80.00 220.00 -50.00 Low
Please suggest me some ways of displaying them properly in a window. If anybody has some code samples provide me.
|
|
|
|
|
Well to format numbers you may use CString::Format method. Anyway your major problem is parsing the line to extract the numbers.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have already read the complete contents of the file, one line at a time from the file using CArchive::ReadString() function and Serialize() function and stored it line by line in CArray variable.
Now I am trying to retreive one line at a time from the CArray variable and add it to the List box control. The content gets added, but the allignment in the file is straight as shown above, but the allignment in the control is not straight.
Note: The content in the file are written by an application after formatting each line.
|
|
|
|
|
Do you mean the text in the file is properly aligned while it is misaligned in the ListBox control?
If the answer is yes, then you probably should choose a fixed-width font (like Courier or Lucida Console ) for your list box.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes you are right. The text in the file is properly aligned while it is misaligned in the ListBox control. I will try the fixed width font like courier.
Thanks
|
|
|
|
|
manohar_balu wrote: The content gets added, but the allignment in the file is straight...
Do you mean mono-spaced? Is it because you are using Notepad to view the file?
If you don't want to change fonts, you could try using an eight-column list control.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I use a listbox in my dialog,but the lisbox does not accept the cursor so i can not click inside it how can make a listbox active that accept an input text in visualstudio 2005? i treid with the listbox property but no success, thanks.
|
|
|
|
|
Are you looking for something like this - Editable ListBox Tutorial[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
no i am looking for listbox control
|
|
|
|
|