|
I was wondering if there is anyway for the modeless dialog to know when the mouse moves focus away from it and to something else.
Right now I created a modeless dialog in one of my views. I do not want it destroyed when finished but just want it to hide. That is easy since it won't be destroyed until the View is gone in this case. However, I also want it to hide when I click something other than it after showing it to tell it I don't need it. I have tried onkillfocus etc but it doesn't work because that is never called.
Any suggestions?
Thanks in advance.
|
|
|
|
|
|
I was wondering if it is possible to remove the button of the app running from the task bar. I do not mean for a dialog based project as Nish has pointed out a great solution. I mean for a SDI or MDI?
Thanks.
|
|
|
|
|
|
I used CListView in an SDI program, I want the view to handle WM_CHAR event but it did not seem to respond to any key stroke at all.
I guess that's because the CListCtrl occupied full area and thus took control over the view, so maybe I should look into LVN_KEYDOWN instead of WM_CHAR? I dunno but neither way worked.
Any help are appreciated.
|
|
|
|
|
Has anybody faced the need to create up to k n-dimensional arrays at runtime? Here is an example:
Suppose that at the moment of running the program, it needs 3 2-dimensional arrays, each of them has different dimensions. The dimensions of each table are stored in another 2-dimensional array. Then, you start creating the names of each array obtaining array1, array2 and array3. Then, how do you:
a) Declare array1, array2 and array3 as dynamic arrays (i.e. double *array1, *array2, array2;)
b) How do you re-declare them, i.e.
array1 = new double[newdimension];
The problem is not how to create the name of the variables, because you can do it by handling strings and concatenating a number so they can be identified.
The main problems are (a) and (b).
If someone has a potential response, please emailme...
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
First, you will need to create an array to hold your dynamic number of variables. Lets say that you are working with doubles, just for the example. You can either mess with dynamic array allocation like this:
double vars[];
vars = new double[3];
...
double newVars[];
newVars = double[5];
memcpy(newVars, vars, sizeof(double) * 3);
delete[] vars;
vars = newVars;
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
Depending on what you are doing, I would recommend that you check out the Standard Template Library (STL). It makes dynamic memory allocation and management a snap, and there are a few tricks that you can do to make accessing the varaibles much easier.
At first glance the vector seems to be what you are looking for, because it is an array that will dynamically grow and manage its own memory. However there are problems with using an array, even if you are doing it the straight C++ way. As long as you will be using STL, I would recommend the map . A map you have a key, and a value that the key represents. You could make the key a string, and the value a double. Here is an example.
#include <map>
using std::map;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
typedef map<char*, double, ltstr> mapVars;
Here is how you will use what we just setup:
mapVars vars;
vars.insert("variable1", double*);
double value = vars["variable1"];
vars.erase("variable1");
Now you have a set of dynamically defined variables with names. Now you need a way to dynamically allocate the array of variables. This case would either be good for a vector or a map . Both of these objects will manage their own memory, and grow automatically for your. Here is how you would use the vector:
#include <vector>
using std::vector;
typedef vector<double> vecDouble;
typedef map<char*, vector<double>, ltstr> mapVecVars;
mapVecVars vars;
vecDouble newVar;
newVar.push_back(1.0);
newVar.push_back(3.14);
newVar.push_back(98.6);
vars.insert("variable1", newVar);
cout << vars["variable1"][0] << endl;
cout << vars["variable1"][2] << endl;
For efficiency, you may want to hold pointers to doubles, and vector<doubles> to prevent all of the data from being copied each time it is accessed, however, the concepts are pretty much the same.
There is a lot of information here, on something that has a million ways to implement. This way I believe will get you up and running the quickest.
The arrays will work, but they will get messy when you have more than a few dynamic variables, and you start to erase varaibles in the middle of the array.
Good Luck
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
I have started a Win 32 Console Application with MFC support and I have created a dialog box with two buttons(RUN PROGRAM and EXIT buttons). I have also selected the class for the dialog box and set up the buttons correctly.
My source files and header files have been inserted into the source and header folders but I don't know how to link my RUN PROGRAM button with the main source file in my program.
Also there was a .cpp .rc and .h file already created which when compiled printed out to the screen Hello from MFC! should these files be deleated and replaced with my own.
caoimhin
|
|
|
|
|
Let's say I have a CString that ends in "Desktop". How can I programmatically check to see if it's the "Windows Special Desktop Folder" for the current user? Anyone know?
|
|
|
|
|
put in a function and check against your string
ITEMIDLIST* pidl;
char szPath[MAX_PATH];
HRESULT hRes = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl);
if(hRes == NOERROR)
SHGetPathFromIDList(pidl, szPath);
IMalloc* palloc;
hRes = SHGetMalloc(&palloc);
palloc->Free((void*)pidl);
palloc->Release();
return szPath;
StartMenu = CSIDL_STARTMENU
Programs in StartMenu = CSIDL_PROGRAMS
StartUp = CSIDL_STARTUP
Recents = CSIDL_RECENT
Favourites = CSIDL_FAVORITES
hope it helps
shotgun
|
|
|
|
|
when using multiple dialogs in mfc how do i create then show a dialog without using DoModal(), ShowWindow(SW_SHOW), doesn't work, not initialized i think...
shotgun
|
|
|
|
|
for show window u can use
DoModal() it is a blocking function
ot
Create(resourceID,NULL);
then
.ShowWindow(SW_SHOW)
it will run parallell..
ok?
try it now..
Renjith
Hai Friends me from Pandalam..and i think there is a sofware behind everything...
so enjoy with the codes...
|
|
|
|
|
I write a application with MFC, I using macro UNICODE and _UNICODE, I put wWinMainCRTStartup. But I cann't display Text in EditBox, ComboBox, Button and other control.
Can you tell me about the method or manual to do that?
Thank you!
|
|
|
|
|
I create two splitter wnd, just like:
|
| wnd2
wnd1 |------------
| wnd3
|
I want to min the size of wnd1 and wnd3, that's my code:
m_wndSplitter.SetColumnInfo( 0, 0, 0);
m_wndSplitter.RecalcLayout();
m_wndSplitter2.SetRowInfo(1, 0, 0 );
m_wndSplitter2.RecalcLayout();
after running, wnd1 can be mined, but no effort on wnd3, what's the problem?
I'm amumu, and you?
|
|
|
|
|
This could be a very simple question but could anyone out there help me. I was hoping that there was an easy way to get a program to draw a line from one set of (x, y) coordinates to another set of (x, y) coordinates. I have looked everywhere but have had no joy so please help.
|
|
|
|
|
::MoveTo(..);
::LineTo(..);
Look up these in MSDN!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Docking windows in Win32 without MFC is what I'm currently
coding. I'm doing it this way:
I have Dock bars, which are just frameless gray child windows. The frame
window consists of four of such dock bars and a client window. The frame
window also resizes all these five windows, e.g. the dockbar at the left is
stretched along the y-axis, the dockbar at the upper side is stretched along
the x-axis etc.
Now there are dock windows. These can dock on a dockbar or float. When
floating, they get a toolwindow frame and a popup style. If, for example, I
wanna dock a toolbar, I can do two things:
a) derive a toolbar class from the dockwindow one, or
b) i can make the toolbar a child of the dockwindow.
DockBar itself is responsible for repositioning and/or resizing the docked
dock windows.
To disable the (de)activation of floating windows and the main window, I use James Brown's method (see http://freespace.virgin.net/james.brown7/tuts/docking1.htm). Do you have any suggestions how to solve the docking problem better?
|
|
|
|
|
I have been trying hard to script a code to search all the *.com and *.exe files in a hard disk recursively and list them in a list box.Till now i have been sucessful partially.Like...right now the program works in a limited way. if u search for all files (*.*) then it will find them even in the subdirectories recursively , but for any other type (*.exe or *.com etc) it will search only the given directory not the subdirectories.So if u can edit this code so that it searches *.com and *.exe at the SAME TIME recursively through out the hard disk and list them in a list box..
Thank You!
void CSearchDlg::OnBfind()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_cGet.ResetContent();
m_cGet.AddString(m_cDrive);
_chdir(m_cDrive);//"C:\\progra~1//Accessories");
m_ccomment.SetWindowText("Searching...");
//m_csearch.SetWindowText("");
GetDlgItem(IDC_BFIND)->EnableWindow(FALSE);
GetDlgItem(IDC_BSTOP)->EnableWindow(TRUE);
//GetDlgItem(IDC_BCONNECT)->EnableWindow(TRUE);
//GetDlgItem(IDC_BCONNECT)->EnableWindow(TRUE);
// search for the filename
SearchDirectory();
// announce when done
m_ccomment.SetWindowText( "Files found");
MessageBox("Done Searching");
GetDlgItem(IDC_BFIND)->EnableWindow(TRUE);
}
void CSearchDlg::SearchDirectory()
{
struct _finddata_t filestruct;
long hnd;
char buffer[_MAX_PATH];
int i=0;
// set _findfirst to find everthing
hnd = _findfirst("*",&filestruct);
// if handle fails, drive is empty...
if((hnd == -1)) return;
// get first entity on drive - check if it's a directory
if(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_DIRECTORY)
{
// if so, change to that directory and recursively call SearchDirectory
if(!(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_HIDDEN))
if(*filestruct.name != '.')
{
_chdir(filestruct.name);
SearchDirectory();
// go back up one directory level
_chdir("..");
}
}
else
{
// if it's not a directory and it matches what you want...
if(!stricmp(filestruct.name,m_cFile))
{
// output the filename with path to debugger
_getcwd(buffer,_MAX_PATH);
strcat(buffer,"\\");
strcat(buffer,filestruct.name);
strcat(buffer,"\r\n");
//OutputDebugString(buffer);
m_cGet.AddString(buffer);
}
}
while(!(_findnext(hnd,&filestruct)))
{
if(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_DIRECTORY )
{
if( !(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_HIDDEN))
if(*filestruct.name != '.')
{
_chdir(filestruct.name);
SearchDirectory();
_chdir("..");
}
}
else
{
if(!stricmp(filestruct.name,m_cFile))
{
_getcwd(buffer,_MAX_PATH);
// extn=::GetFileExt(filestruct.name);
strcat(buffer,"\\");
strcat(buffer,filestruct.name);
strcat(buffer,"\r\n");
//OutputDebugString(buffer);
m_cGet.AddString(buffer);
}
}
}
//m_ctotalfile.AddString((LPCTSTR)i);
_findclose(hnd);
}
|
|
|
|
|
Sorry,I'm very lazy to read all your code,but one time I had the same problem,and solve it in this way:
I use (*.*) for search,so it search in subfolders too,and each file you get,check the last three character of its name and see if it is "exe" or "com",then if it is true show it in listbox.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
When you search only for .exe or .com files, directories will not be found. And so directories will also not be scanned recursively.
Try the following: search for ALL files ("*") and then check if the extension of a found file is .exe or .com. If it is, add it to the listbox. If not, check for directory, and if it isn't a directory, simply skip it.
This will find directories AND .exe/.com files
|
|
|
|
|
hi friendd
i cant read ur code completlly soo
try this
CFileFind oFind;
bool ret=oFind.FindFirstFile("ur Drive\path\*.*");
while(ret)
{
ret=oFind.FindNextFile();
//the n check it is dotz . or ..
if(oFind.IsDots()) continue;
check is it directory
// if(oFind.IsDirectory())
{
then call this function recursivly
}
//else it is a file then get the file name
by usin
GetFileName()/GetFilePath() function search the last three chars if it is a exe or com
then add the name in to a list box /anywhere u want
GetFileName() will give the file name and GetFilePath() wil give the complete path
}
}
try it now..!!
Renjith
Hai Friends me from Pandalam..and i think there is a sofware behind everything...
so enjoy with the codes...
|
|
|
|
|
How can I read data from a text file line after line, as 'Line Input' function in Visual Basic ?
I want to use CFile object or anything else.
Appstmd
|
|
|
|
|
ifstream has a GetLine function, I believe. It's part of iostreams, and unlike CFile does not require MFC, or even a Windows platform.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
CStdioFile f1;
if( !f1.Open( filepath, CFile::modeRead | CFile::typeText ) )
{
MessageBox("Could not open file");
return;
}
CString str1;
while(f1.ReadString(str1))
{
}
f1.Close()
Regards,
Nish
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|