|
The system is launching my app passing the datafile using a shell command or something. This does indeed lock the file, out of my control. If I only needed to worry about launches from explorer I coul dsimply assos the ext with a helper app that simply records he filename of interest and then launches my app after the file has been unlocked. I need to be able to get access to the data in the example of a launch from an email attach whereby the file itself is persistant only while the system launcher is running my app call.
|
|
|
|
|
Is there a way for me to change to color of the font in a static text box?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
on WM_PAINT call SetBkColor. see MSDN for a sample
|
|
|
|
|
A really simple way of doing this and givng you control over quit a bit of the control is to subclass the CComboBox and override the OnCtlColor virtual funtion. Example of changing thetext color follows:
HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
pDC->SetTextColor(RGB(255,255,0));
pDC->SetBkMode(TRANSPARENT);
return m_Brush;
}
In addition to chaging the text color, the disply mode will be transoarent so you don't have to worry about a background color, however, you could change that as well. The m_Brush being returned is a var that is defined in the constuctor so that the entire controls background uses that brush to paint the controls background.
This method can be used on any of the control, listbox, edit, ect.
|
|
|
|
|
Do I always have to set an exception class in my catch function to tell me whats going on? Also how do I know which CException to use? For instance for socket connections?
Thanks
Tom Wright
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You do not have to set exception unless you want to.
CException provides interface to extract basic information for any MFC exception.
As far as I know CSocket does not throw specific exceptions.
|
|
|
|
|
Hi folks, after many months passed in writing a suitable Visual C++ 6.0 wizard I realized that is completely incompatible with the Visual C++ .NET wizard model.Even the reference language is changed: from C++ to Jscript!!! Does anybody know a trick for quickly converting my code or even reuse it making it available in a COM DLL, or whatever?
Regards,
Andrea
|
|
|
|
|
Hi...
I'm trying to use a cListBox object, but the string that I'm displaying gets truncated when it is longer than the width of the listbox. I don't wan't to use a horizontal scroll, so i'm wondering how to make the displayed string continue on the next line. Can anyone tell me?
I've seen that there's a LBS_OWNERDRAWVARIABLE style - which includes that there are variable height involved with this, but creating a CListbox with this style only gives me an error message. Currently i'm using the LBS_STANDARD style. How do i use the LBS_OWNERDRAWVARIABLE one if this is the solution to my problem!?
Regards
Jeffrey
|
|
|
|
|
|
I want to write Bold data (28 points) on a Dialog...against a buutton click
here is code snippet
{
CPen pen;
pen.CreatePen(PS_SOLID,28,RGB(255,0,0));
CDC* pDC=GetDC();
pDC->SelectObject(&pen);
pDC->TextOut("Computer is the killer of nature");
}
it writes data but not bold and Selected color.. Can any one tell where I am doing wrong
|
|
|
|
|
It is not the pen you should change, but the font.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
how I change? tell me....
|
|
|
|
|
for example :
m_Font.CreateFont( 15, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0,
DEFAULT_CHARSET, OUT_CHARACTER_PRECIS,
CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, _T("Arial") );
...
HFONT hfontOld;
hfontOld = (HFONT)SelectObject(dc.m_hDC, m_Font);
::SelectObject(dc.m_hDC, hfontOld);
...
Also, you can maybe search and enumerate the font name just in case "Arial" does not exists.
Max.
|
|
|
|
|
Hi all,
I'm trying to implement an explorer type tree view that allows traversing of the drives. My problem is I'm trying to take into account if a removable drive, cdrom, etc. If theres nothing in the drive, then I want to move the selected item back to the previous one. Problem is, when trying to sift through msdn, it isn't clear how to change the states of the items (at least to me). Here's what I'm trying to do (in general):
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*) pNMHDR;
CString strPath = GetPathFromItem (pNMTreeView->itemNew.hItem);
...
if ((hFind = ::FindFirstFile (strPath, &fd)) == INVALID_HANDLE_VALUE) {
CString temp = strPath + _T("is not accessible\n\nThe Device is not ready\n");
CString temp2 = _T("Exploring ") + strPath;
MessageBox(temp,temp2 ,MB_OK | MB_ICONERROR);
pNMTreeView->SetItemState(pNMTreeView->itemNew.hItem,TVIS_SELECTED,
pNMTreeView->SetItemState(m_prevSelection, // Then what?
} else {
this->m_prevSelection = pNMTreeView->itemNew.hItem;
}
You can see where I am confused, when setting the item states. Am I doing this correctly? What do I need to do in order to properly change the items selected.
Any help in the matter it greatly appreciated. thanks alot!
Dan Willis
|
|
|
|
|
Set on:
SetItemState(hItem,TVIS_SELECTED,TVIS_SELECTED); Set off:
SetItemState(hItem,0,TVIS_SELECTED);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ah. thank you.
Any ideas on how to check to see if there is a floppy or a cd in the corresponding drives? Seems I really should be checking for disc existance, not file existance on these drives.
Any suggestions?
Dan Willis
|
|
|
|
|
You can use this snippet:
#include <windows.h>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
using namespace std;
bool exists_drive(const char letter)
{
char nul_file[]="#:\\NUL";
nul_file[0]=letter;
DWORD error_mode=::SetErrorMode(0);
::SetErrorMode(error_mode|SEM_FAILCRITICALERRORS);
struct _stat st;
int res=_stat(nul_file,&st)==0;
::SetErrorMode(error_mode);
return res!=0;
}
int main(void)
{
for(char drive='A';drive<='Z';++drive){
if(exists_drive(drive)){
cout<<drive<<": OK"<<endl;
}
else{
cout<<drive<<": empty"<<endl;
}
}
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The following code returns no errors and when running through the debugger the set item states all return True, but the Tree View still doesn't update. Any ideas what I'm doing wrong
// if we can't find a file then kaboom, dump an error
if ((hFind = ::FindFirstFile (strPath +_T("*.*"), &fd)) == INVALID_HANDLE_VALUE) {
CString temp = strPath + _T("is not accessible\n\nThe Device is not ready\n");
CString temp2 = _T("Exploring ") + strPath;
MessageBox(temp,temp2 ,MB_OK | MB_ICONERROR);
GetTreeCtrl ().SetItemState(GetTreeCtrl().GetSelectedItem(),
0,TVIF_SELECTEDIMAGE);
GetTreeCtrl ().SetItemState(m_prevSelection,TVIS_SELECTED,TVIF_SELECTEDIMAGE);
GetDocument ()->UpdateAllViews (this, 0x5A, (CObject*) (LPCTSTR) this->m_previousPath);
} else {
// If the selection is valid, then save the selection. If not valid, then
// default back to the previously saved item that was selected. this is to
// maintain consistancy with windows explorer.
this->m_prevSelection = GetTreeCtrl().GetSelectedItem();
this->m_previousPath = strPath;
GetDocument ()->UpdateAllViews (this, 0x5A, (CObject*) (LPCTSTR) strPath);
}
Any ideas? I'm not sure what is going on here, but otherwise my display gets updated just fine.
Dan Willis
|
|
|
|
|
Shouldn't you be using TVIS_SELECTED instead of TVIF_SELECTEDIMAGE ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
um. lol. oh yeah. how stupid of me . gotta read the instructions COMPLETELY!
Thanks!
I'm working the drive check right now. That's pretty nifty. guess I still have a ton to learn. Thanks alot. I really appreciate this.
Dan Willis
|
|
|
|
|
Ok,
Almost there. Thank you for your help so far. Now I'm correctly checking the drives and it is returning properly. I'm correctly setting the selection of the drives.
But now, for example, if the user selects the floppy drive but there's no floppy in it, I get the error returned and change the selection to the previous selection. problem is even though the selection has changed, the floppy drive is still continously attempted to be read. It's almost as if that selected drive still has focus. Another clue is that after I change the selection, there is still a dotted-line box around the floppy drive, which says to me that the CTreeCtrl still has kept the focus on the Floppy drive and not changed it to the drive I switched the selection to. make sense?
Now what This is my last piece for resolving this one. Any help in the matter is greatly appreciated. Thanks a ton!
Dan Willis
|
|
|
|
|
I think I got it.
Seems that the CTreeCtrl::SetItemState does just that, only sets the TreeItem's state. If you want the Tree to actually set focus to that item, you have to also call CTreeCtrl::SelectItem.
Thanks for the help!
Dan Willis
|
|
|
|
|
I'm thinking of writing a frontend to some command-line tools, so I need a way to capture stdout/stderr from the programs I shell to. Any recommendations on how to do this?
|
|
|
|
|
|
All right! Thanks for the super fast reply!
|
|
|
|