|
Hi Everybody,
I've spend some time trying to attach a dialog to winamp 2.xx(like the Plugins for winamp). It's not a Plugindll, but an indipendent exefile. I've tried to do it with;
HWND m_hWinamp = FindWindow("Winamp v1.x",NULL); //Find Winamp
CWnd pWin;pWin.m_hWnd = m_hWinamp; //(Is this possible?) I've tried to generate a CWnd for the Createfunction
//this code is for making the modeless Dialog
CTestDlg *dlg = new CTestDlg;
dlg->Create(IDD_TEST_DIALOG, &pWin);
dlg->ShowWindow(SW_SHOWNORMAL);
But i get an abnormal program termination in the dlg->Create(IDD_xyz, &pWin) line as i run the program. Is it after all possible to attach my own window to an other program, or is there another, better way to something like that?
Thanks for your help! I hope i've explained it clearly
|
|
|
|
|
I dont think you can have a parent window that lives in another exe. And you should use CWnd::Attach if you want to connect a HWND to a CWnd. But I dont think it will work as its in another memory space.
So write a Plugin or inject your own dll into the winamp EXE.
Magnus
|
|
|
|
|
Ok, i've made a dll out of it, and it works as far as i had come good. But now i want to catch some keypresses. I've made it with PreTranslateMessage in the orig. program. But in the dll no messages came through. Nor Mouse, size, key or whatever events...what did i do wrong`?
|
|
|
|
|
When does an entry get written to the registry for the Recent File List? My application is no longer writting these entries and I can't figure out where it's suppose to occur.
|
|
|
|
|
Have you looked into CWinApp::SaveStdProfileSettings()?
|
|
|
|
|
I looked there but I didn't bother to put a breakpoint to see if it was getting there. I had overridden the CWinApp->ExitInstance(). I made a call to the SaveStdProfileSettings() there and everything is back to normal.
Thanks David,
Rome
|
|
|
|
|
I lost those file: StockData.cpp, StockData.h, StockDataList.cpp and StockDataList.h
Everyone has, please send me?
Thanks
|
|
|
|
|
I have been trying all day to get a file open dialog box that would not give me any errors. I have tried the CFileDialog Box which looked like this:
CFileDialog *fileDlg = new CFileDialog(TRUE, "*.exe", NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, "Executable files (*.exe)|*.exe||", GetActiveWindow());
// Initializes m_ofn structure
fileDlg->m_ofn.lpstrTitle = "Half-Life Executable Path";
// Call DoModal
if ( fileDlg->DoModal() == IDOK)
{
m_PATH.SetWindowText(fileDlg->GetPathName());
}
delete fileDlg;
I have also tried the windows api way (non mfc) (this is for a dll, i think i have to change the return type too):
char *Open_File(HWND m_hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH];
ZeroMemory(&ofn, sizeof(ofn));
szFileName[0] = 0;
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = m_hwnd; //handle to your window
ofn.lpstrFilter = "Half-Life Executable (*.exe)\0*.exe\0\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "exe";
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn))
return ofn.lpstrFile;
else
return "";
}
If I open the file dialog box and then click ok after selecting a file it will do this fine in the window:
m_PATH.SetWindowText(fileDlg->GetPathName());
I have a main window and an options screen. The options screen is in a modal state when I call the file dialog and the parent of the file dialog is the options screen. Now up to this stage it is all dandy because I can close the options screen then open the options screen again and it will display the previously selected file because I save it and load it into the text control. But when I close the program I get this:
he thread 0xF14 has exited with code 133 (0x85).
The thread 0xB88 has exited with code 133 (0x85).
The thread 0x4CC has exited with code 133 (0x85).
The thread 0x5B8 has exited with code 133 (0x85).
The program 'C:\Console Connector++\HLCC 0.5a\Debug\HLCC.exe' has exited with code 133 (0x85).
I ended up playing with it all and found out I only get this when I call GetOpenFileName. After using the file dialog I can no longer do file output. By the way im using VC++ 6.0 SP5.
Argghhhh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! It is very urgent cause Im doing an update for my program that people use!!!
Thanks.
|
|
|
|
|
I'm not sure what your problem is. Are you concerned about all those spurious threads? If so, do not worry about them, they're internally launched by the system when you call GetOpenFileName , it's nothing to care about.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Are you concerned about all those spurious threads? If so, do not worry about them
I agree. I have several multithreaded programs that I have written and I see this kind of thing all the time during the execution of the program. These threads are internal to windows and there is no reason to worry about them.
John
|
|
|
|
|
But the thing is after using the file dialog it will NOT let me save any data through file ouput.
|
|
|
|
|
So if you've found that CFileDialog works and GetOpenFileName() doesn't, why are you still trying to use GetOpenFileName()?
While the multiple threads that are being spawned is normal, a non-zero return value is suspect.
Just to rule out a scope problem, change your code to:
OPENFILENAME ofn;
char szFileName[MAX_PATH];
char *Open_File(HWND m_hwnd)
{
ZeroMemory(&ofn, sizeof(ofn));
...
}
I have a hard time using code where functions return auto variables. That whole going-out-of-scope thing can cause hours of grief.
|
|
|
|
|
CFileDialog has the same results as GetOpenFileName.
|
|
|
|
|
Did you read the documentation for GetActiveWindow()? It states:
The pointer may be temporary and should not be stored for later use.
Try removing that last parameter to the constructor.
|
|
|
|
|
Hi,
Still new to programming....kinda confused right now.
I created a MFC app to create a standard text editor.(My base class is Ceditview) I wanted to know how i could have the editor have a set string of text on it as soon as it starts.
Basically I want to make it look like a List Control window. Having strings of text passes into the editor window as a display listing. But I also want to allow for regular paragraphs to be passed in? Can this be done or is there a better solution?
Thanks in advance.
|
|
|
|
|
Use SetWindowText in OnCreate.
Hard to suggest a better solution as I dont know what you want the user to do with the pre defined text. But one is to have a list control and an edit control.
Magnus
|
|
|
|
|
I would like to use the predefined text as a column heading. The only thing is that I will have a mixed form of the things that i want to put in the editor.
For example:
Heading 1 Heading 2 Heading 3 Heading 4 Heading 5
1 345 456 567 678 789
2 987 876 765 654 543
This is a line of code that will be inserted in the middle of my so called "table" of information. There is no defined length. This is all entered from another dialog box.
3 123 234 345 456 567
4 678 789 910 566 556
I hope this makes it a little easier for me to understand. I originally wanted to use a ListControl, but since i need to add that paragraph, i couldn't. Unless i can expand it across the columns.
Thanks again in advance.
|
|
|
|
|
Then you have only the editbox, or Richedit if you want more formation options, as an option, unless you make it a little more advanced and use a grid that has support for text over several columns.
There is a really good grid on Codeproject, but I dont know if it supports text over several columns.
Magnus
|
|
|
|
|
Magnus,
Thanks for your help. Can you tell me how I can do this though? I can't the predefined string to the editbox upon startup of the app. Can you or anyone tell me how to do that? How would I format this text? (something like setw() in a cout statement?)
Thanks again.
|
|
|
|
|
Jay Hova wrote:
How would I format this text? (something like setw() in a cout statement?)
Not unless you are working on a console application. Since you've mentioned the use of an edit control and a list control, you are obviously not working on a console application, but rather a GUI application.
Send formatted text to either using a CString object. It has a nice Format() method.
Here's a very simple example:
void CMyEditView::OnInitialUpdate()
{
CEditView::OnInitialUpdate();
CEdit &Edit = GetEditCtrl();
Edit.SetWindowText("Hello World");
CString str;
str.Format("2 * 2 = %d", 2 * 2);
Edit.SetWindowText(str);
}
|
|
|
|
|
I know that I can use SetupIterateCabinet from Setup API to uncompress .cab-files.
Will this function uncompress zip-files? Is there another ways to work with zip archives in
C/C++?
|
|
|
|
|
|
I have 4 DLLs as following:
CFiles.dll
CExceptions.dll
CXML.Dll
CDataFormat.dll
CExceptions contains an Object factory that follows the Loki Object Factory model as following:
It has a map containing function pointers with enteries such as following:
void CExceptionFactory::InitializeMap()
{
AddToMethodMap(CExceptionFactory::DATABASE_EXCEPTIONS, CreateDatabaseExceptions);
AddToMethodMap(CExceptionFactory::NULL_POINTER_EXCEPTIONS, CreateNullPointerExceptions);
AddToMethodMap(CExceptionFactory::READER_EXCEPTIONS, CreateReadExceptions);
}
Now, within the DataFormat DLL, depending on the type of formatting, I load different DLLs. For instance, if the type is XML, I load the XML dll as following:
case ID_XML:
{
//m_pDataFormat = new XML();
HMODULE hLibrary = 0;
DataFormatProc pfnDataFormat = 0;
GEA pfnGEA = 0;
hLibrary = ::LoadLibrary("CXML.dll");
if(hLibrary != 0)
{
DWORD dw = 0;
pfnDataFormat = (DataFormatProc) GetProcAddress (hLibrary, "CreateXMLSingletonInstance");
dw = GetLastError();
if(pfnDataFormat != 0)
m_pDataFormat = pfnDataFormat();
m_pDataFormat->LoadFile(L"Stocks.xml");
::FreeLibrary(hLibrary);
}
Now if the method LoadFile above fails, it throws an exception by calling CExcpetionFactory class above and CExceptionFactory will try to look inside its Loki map and retrieve the required method as shown below:
CExceptionFactory::CExceptionFactory(int nTypeID, const string & strMessage)
{
InitializeMap();
CreateObject(nTypeID);
if(m_pException != 0)
{
m_pException->Log(strMessage);
delete m_pException;
}
else
{
throw CExceptionFactory(CExceptionFactory::NULL_POINTER_EXCEPTIONS,"Unknown Exception.");
}
}
void CExceptionFactory::CreateObject(int nTypeID)
{
CallbackMap::const_iterator i = m_Callbacks.find(nTypeID);
if( i != m_Callbacks.end())
{
m_pException = (i->second)();
}
else
m_pException = 0;
}
Now, as soon as the code hits (i->second)(); , it leaves the exception dll all together and goes back to the beginning of that case statement above.
I am quite puzzled with this behaviour.
I am guessing I have a function pointer to begin with the loaded DLL and then I am getting a second function pointer and the compiler gets confused, but why should it?
Your help would be highly appreciated.
thanks
|
|
|
|
|
Well it sounds like you have corrupted your stack. Then you can end up any where in your code when calling function.
Magnus
|
|
|
|
|
how do i get WM_KEYDOWN for controls like a CEdit or a CComboBox (not for the window..)? In VC++ i can only use some events like a OnChange() and others.. but can i intercept other messages too?
Thanks,
Bye
|
|
|
|