|
Thanks for your documents,
However, the problem is that my program must know when it will is terminated in order to show some suitable warnings or notices to the user!
____
Tuan
|
|
|
|
|
Hi,
What is the notification being sent from the control when a user is resizing the columns ?
Shay
|
|
|
|
|
The one I usually use is the HDN_ENDTRACK mssage, but you only get this when the finish doing the re-size. You also may need to add this line to get the message maps entries generated by class wizard to work correctly:
m_ListCntl.GetHeaderCtrl()->SetDlgCtrlID(m_ListCntl.GetDlgCtrlID());
Otherwise the HDN_ENDTRACK's all get send with a control ID of 0, and you canbnot tell which came from which control and they also do not map properly unless you change the message map entry.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
First of all thanks !
But whjat if it's not a dialog ?
I created a CFRameWand with a ListCtrl....
Shay
|
|
|
|
|
As long as its the parent window on the control the method should work. The only issue you may have is if you are creating the control yourself dynamically. In such cases you still need that line I mentioned, but just have to add the message map/function prototypes manually:
ON_NOTIFY(HDN_ENDTRACK, IDC_OF_LISTCONTROL, OnEndtrackListControl)
afx_msg void OnEndtrackListControl(NMHDR* pNMHDR, LRESULT* pResult);
void CYourWnd::OnEndtrackListControl(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
*pResult = 0;
}
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
I got all the things you mentioned, but it still does not work.
Does it matter if my listCtrl is part of a splitter window.
My application is a File Manager like with a MainFram that has a TreeView on the left and and listview on the right.
Shay
|
|
|
|
|
Well, I ended up adding this entry in the message map to compensate for the 0 it sends
ON_NOTIFY(HDN_ENDTRACK, 0, OnEndtrack)
Thanks anyway,
Shay
|
|
|
|
|
I have a CEdit control and a CSpinButtonCtrl in a form view. There is no problem for me to connect them so that they work as buddies.
But now I have a special task that should be done. The spin button should look like it is connected to the edit control (UDS_ALIGNLEFT style) but it should not change the text in the edit control. So I only need the "visual connections" but not the "data connection".
Can this be done without using the CSpinButtonCtrl::Create method? I would like to use the exisiting resource with the form view and the 2 controls instead of creating and position them at runtime. So I think my probem is that the UDS_SETBUDDYINT is automatically set if I activate the autobuddy function in the resource editor.
|
|
|
|
|
I use the following code to create a device context in
a static control being part of a CFormView window in
order to draw inside its clients area. This code is in
the OnDraw() method of a CStatic derived class (an instance
of this class in part of CFormView window and OnDraw() is
called in CFormView window OnPaint()).
CWnd* l_pWnd;<br />
l_pWnd = m_pParentWnd->GetDlgItem(m_dwParentId);<br />
CClientDC l_Dc(l_pWnd);
The problem is the following:
my picture is drawn also if its coordinates
are out of client control area. In this way, if my
input data are out of ranges my code paints also the
parent window area.
How can I avoid this problem ?
I'd like that, if picture coordinates are out of
range, it is not drawn !!!
Thanks a lot!
|
|
|
|
|
If I understad your problem correctly you may have to use clipping functions. If you set clipping regions or rectangles the DC will only paint in those regions/rectangles.
See the documentation of the CDC class for details and have a look on the Clipping Functions section in the documentation of the CDC class.
|
|
|
|
|
Can someone plz have a look at my code and tell me what I am doing wrong. I have an SQL server and trying to connect to it using ADO. Only learning ADO a few days but already it is driving me mad connecting to the SQL server I have.
The error message I get is: "Cannot open database requested in login 'Branch'. Login fails."
Here is my code:
try
{
HRESULT hResult;
if(FAILED(::CoInitialize(NULL)))
return;
_ConnectionPtr pConnection;
hResult = pConnection.CreateInstance(__uuidof(Connection));
hResult = pConnection->Open(_T("Provider=SQLOLEDB.1; Data Source=(local);Initial Catalog=Branch;Trusted_Connection=yes;"),
_T(""),
_T(""),
adOpenUnspecified);
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
+ _bstr_t(e.Description());
MessageBox(0,bs,bstrSource, MB_OK);
}
I didn't think I needed to login once I used the Trusted Connection=yes. Once I can get the connection, I should be ok.
Branch is the name of my database.
Thanks.
|
|
|
|
|
You need to specify the User that you use to logon and his password if there is any. For example if the user is sa with no password you should add after trusted connection User Id=sa;Password=;
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
any idea how to create this???
thanx a lot!
|
|
|
|
|
Try CodeJock.com's flashy XFT library. It lets you do Office2003 style toolbars, menus, etc. Very nice looking stuff.
|
|
|
|
|
hy, i already downloaded the trial, but i dont figuered aout, how to do the office2003 style. it is also not documented! i think its in this function:
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
So i would need other styles, but i didnt found styles like Gradient for the TBSTYLE_FLAT,
and it is also not documented
any idea??
andreas
|
|
|
|
|
maby the key is alwo in this function:
(from the customize toolbar sample)
void CMainFrame::OnViewXpmode()
{
xtAfxData.bXPMode = !xtAfxData.bXPMode;
RedrawWindow( NULL, NULL,
RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN );
}
unfortunately there is nothing like a xtAfxData.bOfice2003 flag ...
any ideas?
|
|
|
|
|
Hello,
I have a directory in wich I'll save "archive" files for my application (the format is *.dat, where * is a number). So, when I need to save a new file, I take the last file number and I add 1. So, I have always a file name that doesn't exist in the directory.
How can I do to find the bigger file number in the directory ?
I tried with the CFileFind class but there is a problem with it because if I want to use the GetFileTitle() method, I need to call GetNextFile() before. So if I have just one file in the directory (wich can be different from "0.dat" !!), I will have a problem here!
Any idea?
Thanks!
|
|
|
|
|
That's how CFileFind is meant to work, did you see the example in MSDN?:
<br />
CFileFind finder;<br />
BOOL bWorking = finder.FindFile("*.*");<br />
while (bWorking)<br />
{<br />
bWorking = finder.FindNextFile();<br />
cout << (LPCTSTR) finder.GetFileName() << endl;<br />
}<br />
so you modify the loop to get (untested, but essentially right):
<br />
CFileFind finder;<br />
BOOL bWorking = finder.FindFile("*.dat");<br />
int highest = 0;<br />
int current;<br />
while (bWorking)<br />
{<br />
if(bWorking = finder.FindNextFile())<br />
{<br />
current = atoi((LPCTSTR) finder.GetFileTitle());<br />
highest = highest > current ? highest : current;<br />
}<br />
}<br />
An easier solution is to use a datestamp for the filename instead
--
Ian Darling
|
|
|
|
|
I already tried this but in fact, I made a mistake in my code and so, when I tried with one single file in the directory, I couldn't find it. I corrected the bug and now it works fine!
But I found an easier and faster solution: I keep a file in wich I write this number and some other notitifications infos.
I always look for complicated solutions first !
|
|
|
|
|
The only problem with using the store-number-in-file method is that some *.dat files may get deleted and then your numbering would be off.
|
|
|
|
|
I have a rich-edit where I only want to support *one* font (Tahoma 10pt. etc.) set up at time of constructing of the edit. This works fine when writing in it.
But how do I force a text into this specific font and look when *pasted* in - from some other size and font?
Think it's something about monitoring the clipboard format but I'm not sure?
It makes sense to have a OnPaste() not calling the base impl. and then do the paste-work myself adding my format to it before it goes in - but no such are found anywhere!?
As far as I can see in CWnd I have:
ChangeClipboardChain(...)
SetClipboardViewer(...)
OpenClipboard(...)
GetClipboardOwner(...)
GetOpenClipboardWindow(...)
GetClipboardViewer(...)
and in CRichEdit:
Copy(...)
Cut(...)
Paste(...)
PasteSpecial(...)
CanPaste(...)
I'm a little puzzled here?
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|
|
First, I am sorry, because I adviced yesterday to do so, and I did not answer your second post. :-OThere is actually no OnPaste() routine, do it that way :
Create a class CMyRichEditCtrl derived from CRichEditCtrl .
Create your RichEditCtrl in the resource editor, and assign it a control member : m_MyRichEdt
Go into the automatically generated code, and replace
CRichEditCtrl m_MyRichEdt;
with
CMyRichEditCtrl m_MyRichEdt;
Do not forget to add an #include "MyRichEditCtrl.h" in that same file after
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
Now override PreTranslatemessage like that :
B
OOL CMyRichEditCtrl::PreTranslateMessage(MSG* pMsg)
{
if ((pMsg->message == WM_PASTE))
{
Change font ...
}
else
return CRichEditCtrl::PreTranslateMessage(pMsg);
}
Hope this helps.
~RaGE();
|
|
|
|
|
After few testing (sorry, no time today ), my code snippet lacks one or two things :
First, if (message == WM_PASTE) is not really good, since it can be that several messages are contained in one message. So prefer something like if ((message & WM_PASTE)==0) return ... else paste font;
Secondly, I think you will have to remove the WM_PASTE from the message queue, otherwise, the clipboard contents will be paste (it passes ans passes over again in PreTranslateMessage().
~RaGE();
|
|
|
|
|
OK thanx' - this is a new approch and I understand what you are saying. I'll check it out soon.
Only my feeling now is that this solution seems kind of "emergency exit" and a little primitive as well - there *must* be a better way. Not complaining or anything -
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|
|
Thanx' sharing the ideas!
But I found another way around my CHARFORMAT-problem than using the PreTranslateMessage(...) - here it is.
What I did was that I made the CHARFORMAT-change to the full selection in response to *not* an UPDATE event but a CHANGE ev. As it turned out an update-ev. came over and over again if I did the work on EN_UPDATE - ON_CHANGE was less sensitive. So this is how the final solution looks:
<br />
const void CCalFrameWnd::CCalendar::Note_EditChange()<br />
{<br />
TRACE(_T("Note_EditChange()\n"));<br />
long lChar_Start = 0, <br />
lChar_End = 0;<br />
CHARFORMAT cf_def;<br />
cf_def.cbSize = sizeof(CHARFORMAT);<br />
m_pEdit_Note->GetDefaultCharFormat(cf_def);<br />
m_pEdit_Note->GetSel(lChar_Start, lChar_End);<br />
m_pEdit_Note->HideSelection(TRUE, FALSE);<br />
m_pEdit_Note->SetSel(0, -1);<br />
m_pEdit_Note->SetSelectionCharFormat(cf_def);<br />
m_pEdit_Note->SetSel(lChar_End, lChar_End);<br />
m_pEdit_Note->HideSelection(FALSE, FALSE);<br />
}<br />
So I just force the def-CHARFORMAT on to the entire selection having always set the def-format first. Also I remember to be able to restore to the orig. caret pos.
Btw. Can one make a "ON_EN_REFLECT_CHANGE" for a edit/rich edit - work like this should be held totally inside the class as far as I can se.
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|