|
... speechless
(takes brick and smashes over head)
... thank you
Ryan Baillargeon
|
|
|
|
|
Hello...
I would like to make the background of a window invisible, it is a CWnd that I've derived from a CStatic and I paint some rectangles over it, but I want to show only the rectangles showing the background dialog image...
Is this possible?
and if so, could you tell me how to do it?
thank you very much...
|
|
|
|
|
Do the drawing in OnEraseBkgnd without calling CStatic::OnEraseBkgnd in your overriden handler. Also, invalidate the corresponding portion of the parent window every time the drawing changes.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
I have a splitter with 2 CRichEditViews.. From with in one of the views I do a SetSel(-1,-1) to put my caret at the end of the edit control.. Next I do a SendMessage(EM_SCROLLCARET) to scroll the view to the end of the control.. The control receives the message but the view isn't scrolled until it gets focus.. This is a work around but I don't want to throw the focus around.
GetRichEditCtrl().SendMessage(EM_SCROLLCARET);
CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
if(pMain)
{
pMain->m_wndSplitter.SetActivePane(0,0);
pMain->m_wndSplitter.SetActivePane(1,0);
}
Is there any way to force the control or view to do what it's supposed to do with out messing with the focus\active pane? I've tried Invalidate RedrawWindow etc.. on both the view and the control..
Rob
|
|
|
|
|
I overriden DTN_DATETIMECHANGE of my datetimepicker control.When I change the time with arrow key it does not call and each 3 time it does not called.I overriden ONKEYUP and change time with scrollbar have the same problem.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hy people!
I have a RichEditCtrl, and sometimes I add some lines of text into it. For each line I have one CHARFORMAT struct, and it works fine when I insert the first line.
But when I try to insert more lines, the first loses his format.
And the new one works fine.
I'll post my code here, it makes things more easy if someone could help me. I call this function every time that I have to insert a line into de Edit.
thanks all.
nPosTextIni = m_strRichEdit.GetLength();
m_strRichEdit += (strRemetente + " ("+tmp+") :\n");
UpdateData(FALSE);
UpdateData(TRUE);
nPosTextEnd = m_strRichEdit.GetLength();
m_ctrlRichEdit.SetSel(nPosTextIni, nPosTextFim);
if(bSomething)
m_ctrlRichEdit.SetWordCharFormat(cf_usrOrigem);
else
m_ctrlRichEdit.SetWordCharFormat(cf_usrDestino);
nPosTextIni = m_strEditHistorico.GetLength();
m_strRichEdit += strMsg;
m_strRichEdit += "\n";
UpdateData(FALSE);
UpdateData(TRUE);
nPosTextFim = m_strRichEdit.GetLength();
m_ctrlRichEdit.SetSel(nPosTextIni, nPosTextFim);
m_ctrlRichEdit.SetWordCharFormat(cf_texto);
Ricky
|
|
|
|
|
Are you sure your SetSel is only selecting what you want to change? If it selects the whole control then everything will get changed.. I would double check the setsel
|
|
|
|
|
Yes Rob,
I'm selecting ok!
Does have an function or something that must be overriding?
Must I reformat all my RichEdit every time that I insert a new line?
I'm confused because all that I'm doing is inserting a new line with different colors, and this crashs the other lines already formated...
well, I'll continue searching for something here, thanks for your help
Ricky
|
|
|
|
|
Just a thought.. you might try using SetSelectionCharFormat() instead of SetWordCharFormat().. Not sure if that will help..
I am assuming your making some type of chat program. I have had the same problems in the past, I wanted to color my name blue and leave the other persons name default so I had to create a loop and re-color each occurance of my name each time a new line was added. I have seen some syntax color edit controls here on codeproject and on codeguru.. you may check them out, they might be doing something that you are missing..
You might alos look into stream in and stream out.. Then when you receive a message you could color the whole line one color and when you send messages color it a different color.. Just a thought..
Good luck,
Rob
|
|
|
|
|
That's right Rob, I'm doing a chat program
I'm studing some code samples that I take from codeguru.
Thanks very much for your Help Rob,
cheers!
Ricky
|
|
|
|
|
Can someone tell me how I can rotate some text i am putting on a CDC?
Im currently creating the font, then using TextOut() to draw the text when displaying and printing, is there a way to rotate the text 45 degrees?
thanks in advance for any suggestions!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
I believe you can specify the text rotation when you create your font. Check out CFont in MSDN for more info... then it's just a matter of selecting that font, and then calling TextOut as normal.
If you aren't using MFC, I think this item is also in the LOGFONT structure.
Even a broken clock is right twice a day.
|
|
|
|
|
In the LOGFONT structure there is a data member called lfEscapement. Before you pass the LOGFONT structure to a CreateFont call, assign some value to this member and that should rotate the text. Below is some code I use in a view that makes use of rotated text.
BOOL CRedsView::CreateFont(CFont& Target, LPCSTR Name, int PointSize, int Weight, BYTE bItalic, BYTE bUnderline, long nEscapement)
{
LOGFONT LogFont;
LogFont.lfHeight = PointSize;
LogFont.lfWidth = NULL;
LogFont.lfEscapement = nEscapement;
LogFont.lfOrientation = NULL;
LogFont.lfWeight = Weight;
LogFont.lfItalic = bItalic;
LogFont.lfUnderline = bUnderline;
LogFont.lfStrikeOut = NULL;
LogFont.lfCharSet = ANSI_CHARSET;
LogFont.lfOutPrecision = OUT_TT_PRECIS;
LogFont.lfClipPrecision = CLIP_TT_ALWAYS;
LogFont.lfQuality = PROOF_QUALITY;
LogFont.lfPitchAndFamily = TMPF_TRUETYPE|FF_SWISS;
strcpy(LogFont.lfFaceName, Name);
return ( Target.CreateFontIndirect(&LogFont) );
}
void CRedsView::CreateAllFonts(double dZoomFactor)
{
CString FontFaceName("Arial");
if ( !CreateFont(m_fHeading, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.75*dZoomFactor), FW_BOLD, 0, 1) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fSubTitle, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.5*dZoomFactor)) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fSubTitle1, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.5*dZoomFactor), FW_BOLD) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fSubHeading, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.5*dZoomFactor), FW_BOLD, 1) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fSubHeading1, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.5*dZoomFactor), FW_BOLD, 0, 1) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fNormal, (LPCSTR)FontFaceName, (int)(m_nFontSize*dZoomFactor)) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fNormal10, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.25*dZoomFactor)) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
if ( !CreateFont(m_fAngled, (LPCSTR)FontFaceName, (int)(m_nFontSize*1.5*dZoomFactor), FW_NORMAL, 0, 0, -750) )
TRACE("A call to the CreateFont method has returned FALSE.\n");
}
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
Set the nOrientation LOGFONT member variable to 450 for a 45 degree shift, 900 for 90 etc when creating your font.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
thanks a ton for everyone's help
i had tried adjusting the nOrientation on the CreateFont() call, but it wasn't doing anything.. i ended up changing the nEscapement to 450 and that worked.. turned out i was using too small of units.. i had been trying 45 hehe
anyways it seems it is nEscapement, as it didn't work for nOrientation, however the descriptions in msdn makes it sound like you could do it either way..
thanks
CFont fnDemo;
fnDemo.CreateFont(
1200,
0,
450,
0,
FW_BOLD,
TRUE,
TRUE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
"Courier New");
CFont* pOldFont = pDC->SelectObject(&fnDemo);
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
dazinith wrote:
anyways it seems it is nEscapement, as it didn't work for nOrientation, however the descriptions in msdn makes it sound like you could do it either way..
It's one of those confusing things in GDI where the authors felt it should work a certain way, but didn't bother actually implementing on systems where it mattered. nOrientation *will* actually take effect if you've called SetGraphicsMode(GM_ADVANCED), but only on WinNT or greater. To be on the safe side, set nOrientation to the same value as nEscapement - it's usually gonna be what you want anyway.
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
I have a Davis Instrument Weather station and it comes with software that downloads the data from the station and writes it to binary data files. One file per month is created. The only documentation (see below) I could find for the data file format seems to indicate it is a C++ created binary file. Davis Instruments tech support was unwilling to provied any additional information. I want to use Visual C++ .net to read the data out of the files and load it into a SQL database. The problem is I am a C++ novice and cannot seem to find any good examples of dealing with files like this. Deserialization was something I was looking at but if I understand correctly you can only store and thus read one object in one file. Can anyone tell me what would be the best approach to extracting the data contained in these files?
Thanks,
Frank Kloskowski
Data File Structure
// Data is stored in monthly files. Each file has the following header.
struct DayIndex
{
int recordsInDay;
long startPos; // The index (starting at 0) of the first record for the day.
};
// Header for each monthly file.
class HeaderBlock
{
char idCode [16]; // = {'W', 'D', 'A', 'T', '1', '.', '0', 0, 0, 0, 0, 0, 0, 0, 1, 0}
int daysInMonth; // this field is no longer used.
long totalRecords;
DayIndex dayIndex [31];
};
// After the Header are one or more records with the following format
class WeatherRecord
{
int packedTime;
int hiOutsideTemp;
int lowOutsideTemp;
int insideTemp;
int outsideTemp;
int barometer;
unsigned char insideHum;
unsigned char outsideHum;
int dewPoint;
int rain;
unsigned char windSpeed;
unsigned char hiWindSpeed;
int windChill;
unsigned char windDirection;
unsigned char archiveInterval;
};
|
|
|
|
|
Hi Frank,
Serialization is of little interest here. What matters is the information about the exact layout of the data. Assuming the classes you provide are accurate with respect to layout, reading could be done like this (pseudocode follows):
#pragma pack(push,8)
#pragma pack(pop)
...
FILE *fp=fopen("inputfile","rb");
...
WeatherRecord wr;
fread(&wr,sizeof(wr),1,fp);
... Play with this until you're sure you've gotten it right (for instance, after reading a header block the idCode should have been put into place, etc.) Another subject you might have to take into account is endian-ness (whether numbers are stored from least significant to most significant byte or the other way around). Check if the numbers are consistent --if they are too large some endian-ness change might be needed.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquin. I will give it a try.
Frank Kloskowski
|
|
|
|
|
I have a requirement (in a dialog based application) to show the system menu on click of a button, placed somewhere in the middle of client area.
So I tried this code.
void CMenuTestDlg::OnMenuButton()
{
CMenu * sysMenu = GetSystemMenu(FALSE);
if(sysMenu != NULL){
sysMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, 40,40, this);
}
}
Using this, the menu appears but it doesnt function, i.e, I select minimize or close menu item nothing happens.
Am I missing anything here? Gurus Please help me..
Thanks in advance,
Subrahmanyam
|
|
|
|
|
TrackPopupMenu seems not to work well with system menus. Try this workaround:
void CMenuTestDlg::OnMenuButton()
{
CMenu * sysMenu = GetSystemMenu(FALSE);
if(sysMenu != NULL){
int menuID=sysMenu->
TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |TPM_RIGHTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD, 40,40, this);
if(menuID){
SendMessage(WM_SYSCOMMAND,menuID,0);
}
}
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Man,
You rock!!
Thanks for the help. Its working great.
regards,
Subrahmanyam.
|
|
|
|
|
When user selects command from system menu opent by usual way, your dialog gets WM_SYSCOMMAND message. When command is selected from the menu created by OnMenuButton(), dialog gets WM_COMMAND message. Play with Spy++ to find the way to handle this.
|
|
|
|
|
Alex,
Thanks for your reply and the pointer to solution.
Joaquín has posted code and made my day
Thanks to both of you,
Subrahmanyam.
|
|
|
|
|
Can somebody help me.
What is the most elegant way to get a uniq filename under windows.
|
|
|
|
|