|
1. Use GetModuleFileName to get the full path to the program, then use something like splitpath to grab the drive letter.
2. Use GetDriveType
In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock!
-- Harry Lime
|
|
|
|
|
Thankx; I was looking for just these functionalities (without knowing their names
|
|
|
|
|
I'm having trouble placing the cursor in the correct spot in an edit box after writing content to it. It would seem that after CEdit::SetWindowText() the cursor is placed at the beginning (or left side) of the edit box. I want it to be placed on the right (i.e. at the end of the text that was just written). The following code does NOT do the trick:
// m_editOffset is a CEdit and boxtext is a std::string
// which I have parsed to ensure only numeric values
<br />
m_editOffset.SetWindowText(boxtext.c_str()); <br />
// At this point the caret is placed at the leftmost
// position in the edit box. So I'll calculate
// where its new position is supposed to be:
// The correct caret 'x' position follows the pattern
// 1,7,13,19 etc.. I've already verified this.
<br />
int caretOffset = boxtext.size() * 6 + 1; <br />
m_editOffset.SetCaretPos(CPoint(caretOffset,1));<br />
Now here is the strange part. The following code DOES work the way I want:
<br />
m_editOffset.SetWindowText(boxtext.c_str());<br />
AfxMessageBox(boxtext.c_str());<br />
int caretOffset = boxtext.size() * 6 + 1; <br />
m_editOffset.SetCaretPos(CPoint(caretOffset,1));<br />
Yup, the only difference is the call to AfxMessagBox() before setting the caret position . After I get done closing the message boxes the caret magically appears in the correct position.
Does anyone know what is going on? Clearly, I cant have my users closing message boxes for no good reaso at all.
|
|
|
|
|
Use CEdit::SetSel() instead, like:
m_editOffset.SetWindowText(boxtext.c_str());
m_editOffset.SetSel(boxtext.length(), boxtext.length());
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
David,
You rule!
Minor technicality, the code needed to be:
<br />
m_editOffset.SetSel(boxtext.length(), boxtext.length(),TRUE);<br />
... as the compiler had problems resolving ambiguity in SetSel().
Now out of curiosity, does anyone know why the message box code in my originial post makes things work?
|
|
|
|
|
gremlinimp wrote:
Now out of curiosity, does anyone know why the message box code in my originial post makes things work?
Well it probably wasn't working the way you intended. What was happening was after the Message box was dismissed the edit box was receiving the focus; the windows default is to add the cursor end of an edit box.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Interesting, so I wonder if a call to SetFocus() after setting the caret position would have worked in my original code? The code David suggested seems 'more right' than my position calculations but my curiousity is piqued nonetheless. I'm on to breaking other parts of my code at this point, but I'll be sure to play around with the SetFocus possibility in the future.
Thanks!
Oh, and I would liken debugging more to removing needles from a needlestack.
|
|
|
|
|
SetFocus is not as reliable as David’s suggestion.
gremlinimp wrote:
Oh, and I would liken debugging more to removing needles from a needlestack.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
ok, not striclty c++, but i dunno where else to put this
i have made a program in python, which gets an edit control from another program, and get's its content. Becuase its content is constly changing, what is the best method of getting the changing content.
My first thoughts were a continuous loop of some sort, but i think this will be wasteful
is there anyway of setting up something which listens and notifies my main code when changes occur?
cheers
|
|
|
|
|
Anonymous wrote:
have made a program in python, which gets an edit control from another program, and get's its content. Becuase its content is constly changing, what is the best method of getting the changing content.
if you can use Window Message in python, you can use WM_GETTEXT message to retrieve content of an edit box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have a Oracle 9i installed on server and Want to connect and process QUERIES, PROCEDURES AND FUNCTIONS ON IT THROUGH 3 DIFF MACHINES.
HOW TO EATABLISH A CONNECTION?
HOW TO PROCESS QUERIES?
I WANT THE ODBC DIALOG BOX TO BE CLOSED WHILE ESTABLISHING CONNECTION IE WHEN MY SYSTEM LOADS IE SYSTEM IS OPEN IT SHOULD CONNECT AUTOMATICALLY TO THE ORACLE.
i NEED TO CONNECT THROUGH SYSTEMDSN PLS PLS HELP ME IN THE CODE FOR DSN THAT SYSTEMDSN NEED TO BE CREATED ONLY ON SERVER OR EACH AND EVERY MACHINE
PLS MAIL ME URGENT
** A Fighter Never Loses !!!!
|
|
|
|
|
Hi
I'm very fresh with MFC programming.
My program works on the background, when the user clicks on a predefined hot key, the app performes the action and what I'm trying to do is to notify the user with an ok image on top of the screen for less than a second and disappear.
I tried to create a dialog without window borders with a picture control within, the problems i encountered are:
a. The picture control takes only bmp files which are can not be transparent.
b. Whenever i set the dialog as transparent it is not become on top and start to act weird.
The folowing code works fine except that the picture is not transparent.
1. When the action performed:
<br />
AfxBeginThread(notify,NULL);<br />
2. Opennig the dialog:
<br />
UINT notify(LPVOID pParam){<br />
NotifyDialog saved;<br />
saved.DoModal();<br />
return TRUE;<br />
}<br />
3. The initialization of the dialog:
<br />
BOOL NotifyDialog::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
hDlg = this->m_hWnd;
AfxBeginThread(WaitingToHideIcon,(LPVOID)NULL);<br />
return TRUE;<br />
}<br />
4. Closing the dialog:
<br />
UINT WaitingToHideIcon(LPVOID pParam){<br />
Sleep(600);<br />
EndDialog(hDlg,1);<br />
return 0;<br />
}<br />
5. The resource of the dialog and the picture control:
<br />
IDD_NOTIFYDIALOG DIALOGEX 0, 0, 58, 71<br />
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_SYSMENU<br />
EXSTYLE WS_EX_TOPMOST<br />
FONT 8, "MS Shell Dlg", 400, 0, 0x1<br />
BEGIN<br />
CONTROL 143,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,0,<br />
58,71<br />
END<br />
<br />
IDB_BITMAP1 BITMAP "res\\OkHandSign.bmp"<br />
I would love to get suggestions and improvements on how to do this
Thanks a lot
Mamtz
|
|
|
|
|
mamtz wrote:
The picture control takes only bmp files which are can not be transparent.
This[^] article may help.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
When variable i increase to some value(not always definite),exception occurs,is it another bug of ie6.0? Thx a not!
Source code goes as follows:
IHTMLDocument2* pDoc2=NULL;
IHTMLElementCollection* ppCollection=NULL;
IDispatch* ppvdispOption=NULL;
pView->GetDHtmlDocument2(&pDoc2);//pView--a pointer to CHTMLEditView,already asigned with enougth memory
Assert(pDoc2);
pDoc2->get_all(&ppCollection);
Assert(ppCollection);
ppCollection->get_length(&Count);
for (long i=0;i {
_variant_t index ;
index=i;
try
{
ppCollection->item(index,index,&ppvdispOption);
}
catch (...)
{
tagstr.Format("%d",i);
AfxMessageBox(tagstr);
return FALSE;
}
if(!ppvdispOption)
continue;
ppvdispOption->QueryInterface(IID_IHTMLElement,(void **) &pElement);
ppvdispOption->Release();
//.........
}
|
|
|
|
|
how can I change alignment of columns of header control? (not text of columns)
I want the fist column be shown in the right of list box.
|
|
|
|
|
You already created a thread for your question below.
I don't understand your question. Could you rephrase it?
Do you mean the text in the header control's alignment: left-align, center-align, right-align?
this is this.
|
|
|
|
|
when you create the fist column of the header control, it appearers at the topleft of listbox (regardless of the alignment of its text). when you create another column, it appears in right of the first one.
I want the first column be appeared at the topright.
|
|
|
|
|
read more carefully about the method
int InsertItem( int nPos, HDITEM* phdi );
it provides all you what
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
read carefully my question!
I want to apply right to left order to columns, not to text of items.
|
|
|
|
|
Just use zero for the index when you insert the columns.
<br />
InsertColumn(0, _T("Column far right"));<br />
InsertColumn(0, _T("Column 2nd from right"));<br />
InsertColumn(0, _T("Column 3rd from right"));<br />
If you need it so the entire list control is flush with the right side on the control (say for arabic/hebrew reading) you'd need to set the Right to Left RTL Layout setting in the dialog that contains the control.
In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock!
-- Harry Lime
|
|
|
|
|
Insert a temporary column first, insert the other columns, then delete the temporary column, like:
m_lcFooter.InsertColumn(0, _T("David"));
m_lcFooter.InsertColumn(1, _T("Right Justified"), LVCFMT_RIGHT, 580);
m_lcFooter.InsertColumn(2, _T("Left Justified"), LVCFMT_LEFT, 75);
m_lcFooter.DeleteColumn(0);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi guys,
How to set the dialog title?
Thank you.
Best regards,
KHLin.
|
|
|
|
|
MFC:
SetWindowText("here is the title");
Win32:
SetWindowText(hWnd,"title here");
this is this.
|
|
|
|
|
hi,
i have a SDI application in which i want to add some text on the menus. for example the way we have the Add to Favourites in the Internet Explorer menu. so how do i implement that in my application. but in this case i want the data in a text box to be added (functionality is same as that of the Add to Favourites) . can anyone help.
thanks
aditya
|
|
|
|
|
To insert a new item:
CMenu* m;<br />
m = AfxGetApp()->GetMainWnd()->GetMenu();<br />
m = m->GetSubMenu(2);
m->AppendMenu(MF_ENABLED,253,"new item");
When the menu item is clicked, you need a menu-command-range hander in the message-map macro in the .cpp file:
ON_COMMAND_RANGE(200,400,OnMyMenu)//change the first and second parameter to the range you will provide in the second param to AppendMenu()
The implementation will be:
void CMySdiView::OnMyMenu(UINT nItem)<br />
{<br />
}
Now nItem contains the second parameter you gave in AppendMenu(). So you know which one was clicked.
One thing to note is that you must have at least a sub-item in the menu in the resource. Let it be a separator. When no sub-items are present, it gives a headache.
this is this.
|
|
|
|
|