|
I'm using the latest Platform SDK from MS and have the latest SP for VC++6.0 installed on an ME platform . . . for some reason when I try to register a window class with RegisterClass() or RegisterClassEx() the call fails and GetLastError() returns ERROR_CALL_NOT_IMPLEMENTED. Does anyone know what's going on? It seems odd to me that I can't create the main class that Windows is founded on.
-Michael
|
|
|
|
|
Please be more specific - how do you initialized members of the WNDCLASS or WNDCLASSEX struct?
In the docs for RegisterClassEx, I've found the following info:
"Windows 95: RegisterClassEx fails if the cbWndExtra or cbClsExtra member of the WNDCLASSEX structure contains more than 40 bytes."
Not sure if this applies to WinME.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Sorry . . . here is my WNDCLASS struct. I've found that RegisterClass() works when compiled on VC++ without the Service Packs and without the Platform SDK upgrade.
Could there be some variable I need to #define?
MSG msg;
WNDCLASS wc;
CREATESTRUCT cs;
wc.style = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.hCursor = NULL;
wc.hIcon = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "SystemControlClass";
wc.hbrBackground = HBRUSH(GetStockObject(WHITE_BRUSH));
if (!RegisterClass(&wc))
{
#ifdef _DEBUG
DWORD dwLastErr = GetLastError(); // I check this variable in the
// debugger.
#endif
return FALSE;
}
-Michael
|
|
|
|
|
On my machine (W2K, VC++ 6.0/SP5, no Platform SDK update) it also works.
RegisterClass is #defined in winuser.h as RegisterClassA or RegisterClassW, depending on the value of UNICODE macro:
#ifdef UNICODE
#define RegisterClass RegisterClassW
#else
#define RegisterClass RegisterClassA
#endif // !UNICODE
Assuming that in your project UNICODE is definded, your program will link with RegisterClassW. I don't have ME machine, so I can't check if this OS exposes 'stub' for RegisterClassW that simply returns ERROR_CALL_NOT_IMPLEMENTED. Without the stub, your program wouldn't load - you'd get the error message box saying that loader can't find the imported function in the USER32.DLL
You can check which variant your program calls by using depends.exe. The function should be exported from USER32.DLL.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Hi.
I'd like to close an application by sending to its main window the WM_CLOSE message.
What I do is getting the ID of the process I want to stop, and then I use EnumWindows()
function to get all top-level windows in the screen and in the callback function
EnumWindowCallBack(), I compare the process ID with the ID of each top-level window.
When the ID is the same, I send to the window the WM_CLOSE message thanks to ::PostMessage().
But, unfortunately, it doesn't work all the times. It seems that the windows I get in
the callback function EnumWindowCallBack() are not the main windows of the applications
I want to stop... For example, with calc.exe, the window is closed after having posted
the WM_CLOSE message twice but the process calc.exe is still running without a window...
Has anyone already met this problem ?
Is there a way to be sure to get the right window of an application (and not a child window
that doesn't handle the WM_CLOSE message) ?
Thanks.
|
|
|
|
|
Knowledge Base article Q178893 - "HOWTO: Terminate an Application 'Cleanly' in Win32" - deals with these issues. Basically, you should call WaitForSingleObject after posting WM_CLOSE.
You can find the article online:
http://support.microsoft.com/support/kb/articles/Q178/8/93.ASP
Cheers
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
How must I amend the code generated by the Appwizard to prevent the document view from appearing upon start up?
I am making a SDI App.
desperdao...
|
|
|
|
|
Basically, SDI app always has some document created. You have to be tricky if you don't want a document. You can check the "C++ Q & A" column by Paul DiLascia in the November 1996 issue of Microsoft Systems Journal - the author describes the necessary steps.
You can find the article in the MSDN, also online:
http://msdn.microsoft.com/library/periodic/period96/S204D.htm
Cheers
Tomasz Sowinski
|
|
|
|
|
This is how I did it in my app's InitInstance(). (Its an MDI app though):
.
.
.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//disable LOADING OF A NEW FILE AT STARTUP
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
.
.
.
Look up CCommandLineInfo in MSDN for more info
Josh
josh@schroff.com
|
|
|
|
|
I use m_pDesktopFolder->ParseDisplayName(...);
The problem is it works fine when I parse a name from a "real" directory that I created myself named "Spel", but when I try to parse the name of a virtual folder "Den här datorn" (Swedish; aka "My computer" in English) the function fails.
So: How can I get the PID of a virtual folder such as "My computer" with the ParseDisplayName(...); I tried both English and Swedish name of the virtual folder, none works.
Any ideas?
Cheers,
Henrik
|
|
|
|
|
Hi,
I want to make a menu bar like in Internet Explorer, so the user could b able 2 locate the toolBar and the menuBar at the same line.
Does anyone have done it before?
Please help me...
|
|
|
|
|
Hi,
look at the Platform SDK under "User Interface Services/Windows Common Controls/
Common Controls How Tos/Creating an Internet Explorer-Style Menu Bar"
|
|
|
|
|
Hi all!
How can I set the icons for the files in the list ctrl in a CFileDialog?
The files don´t have any icons associated with them and I don´t want that either.
I also would like not to have the file extensions shown.
Thanks,
Daniel
|
|
|
|
|
Hi there!
I am trying to build a Dialog-based application which is much like the Visual C Class Wizard.
I have played around with a CTabCtrl on the dialog box but I haven't had much luck thus far.
Can you give me some hint as to how you would create an application like that?
Also, I was wondering whether instead of dumping a CTabCtrl on my dialog, I could attach a CPropertySheet to my CDialog?
|
|
|
|
|
If it doesn't bother you that the standard buttons of a property sheet are always there use it.
If you do - like I do in my dialog-based-application now - you have to use the CTabCtrl.
The difference is that you have to create a dialog for each rider of the tab. The tab itself
is just a container. So by selecting the riders of a tab you just call up a user-defined dialog.
- Put a tab (like
IDC_TAB1 ) in your dialog (CMyDialog ) with the dialog editor
- Open the Class-Wizard and attach a CTabCtrl-Member-Variable (like
MyTabCtrl ) to your tab-resource (IDC_TAB1 )
- Then you have to tell your tab about the number of riders and their names (with a
TC_ITEM structure)
BOOL CMyDialog::OnInitDialog()<br>
{
CDialog::OnInitDialog();
<br> TC_ITEM TabCtrlItem;
TabCtrlItem.mask = TCIF_TEXT;
<br> TabCtrlItem.pszText = "Name of the Rider 1"
MyTabCtrl.InsertItem(0, &TabCtrlItem);
<br> TabCtrlItem.pszText = "Name of the Rider 2"
MyTabCtrl.InsertItem(1, &TabCtrlItem);
<br> TabCtrlItem.pszText = "Name of the Rider 3"
MyTabCtrl.InsertItem(2, &TabCtrlItem);
}
- Derive a dialog-class (like
CMyFirstRiderDialog ) from CDialog
- You should create another dialog resource (like
IDD_MY_FIRST_RIDER ) that represents the content of your rider
- In the function
void CMyDialog::OnShowWindow(BOOL bShow, UINT nStatus) you'll have to create your rider-dialog.
void CMyDialog::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus)
<br> if(bShow)
{
MyFirstRiderDialog->Create(IDD_MY_FIRST_RIDER, MyTabCtrl.GetActiveWindow());
MyFirstRiderDialog->ShowWindow(SW_SHOW);
}
}
- In the Message Handler of your
TCN_SELCHANGE and TCN_SELCHANGING message of your IDC_TAB1 object you have to destroy your MyFirstRiderDialog and create the dialog dedicated to your other tabs.
void MyDialog::OnSelchangingZone(NMHDR* pNMHDR, LRESULT* pResult)
{
switch(MyTabCtrl.GetCurSelection())
{
case 0:
CMyFirstRiderDialog->DestroyWindow();
break;
<br> case 1:
CMySecondRiderDialog->DestroyWindow();
break;
<br> default:
ASSERT(0);
break:
}
}
void MyDialog::OnSelchangZone(NMHDR* pNMHDR, LRESULT* pResult)
{
switch(MyTabCtrl.GetCurSelection())
{
case 0:
MyFirstRiderDialog->Create(IDD_MY_FIRST_RIDER, MyTabCtrl.GetActiveWindow());
break;
<br> case 1:
MySecondRiderDialog->Create(IDD_MY_SECOND_RIDER, MyTabCtrl.GetActiveWindow());
break;
<br> default:
ASSERT(0);
break:
}
}
I think with this you can find the missing links in the VC-manual.
Manfred
---
Programming is knowing...
|
|
|
|
|
Ok, I'm a beginning MFC user so I'm probably just doing something stupid...
Anyway, I added class members for my list boxes using the Class Wizard window. Anytime I try to do anything with them in the OnInitDialog() function I get an assertion error because I think my list box members aren't initialized or something. Is there anything i have to know about using them? Do I have to do a data exchange before I use them or something, or somehow initialize them?
|
|
|
|
|
You must call DoDataExchange() once to hook up your member variable to the control. CDialog::OnInitDialog() does this, so put your code after the base class function call.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi there,
I was wondering how you create an application that has a little icon on the
bottom right hand side...kind of like Real Player or McAfee or so many other
application that have that little icon in the bottom right hand side of Windows,
which you can click to launch the application dialog.
thanks
|
|
|
|
|
Hello, the codegurus around the world.
Check Master Chris Maunder's code.
http://www.codeproject.com/shell/systemtray.asp
(Acutally, I'm looking for the codegurus web site, but I couldn't find his code. )
I remembered that he posted his code at codegurus about two and half years ago.
He commented in those days that he can't believe that some company gets the money
from this kind of codes.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hello,
I got a small problem (or rather question)...
global:
-------
SHGetDesktopFolder(&m_pShellFolder)
// the nFolde value can be diffrent,, also CSIDL_DESKTOP.. depends what button user press
SHGetSpecialFolderLocation(NULL, nFolder, &m_ppidl);
func:
-----
IShellFolder* pFolder;
IEnumIDList* pEnumIds;
if (::GetSize(m_ppidl) == 2)
{
// if the user is in the root path (desktop folder) do this...
m_pShellFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnumIds);
pFolder = m_pShellFolder;
pFolder->AddRef();
}
else
{
// if the user is in a folder that is BELOW the desktop do this.... the pidl is
// a full path list in both cases (ie it holds the desktop id as first entry)
m_pShellFolder->BindToObject(m_ppidl, NULL, IID_IShellFolder, (LPVOID *)&pFolder);
pFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnumIds);
}
// after this the enumaration process starts and I use pFolder->GetAttributesOf
// and pFolder->GetDisplayNameOf...
.
.
.
pFolder->Release();
I got this code. Anyway as you might notice I do pFolder = m_pShellFolder.
My question is, can this be dangerous when I do pFolder->Release(); since both pointers point at the same memloc...?
(SIDENOTE)
If GetSize returns 2 I assume that the pidl tells you that your in the root (DESKTOP)
else your in a subfolder to the root
, my code is supposed to add to the pidl list as the user goes down in the folder structure..
(THE QUESTOIN )
So my question is, as I said, is it safe to do pFolder = m_pShellFolder; and then release pFolder later with pFolder->Release()?..
Will this destroy m_pShellFolder (or make it unusable) (it worked tough i dunno if its safe?)?
What im trying to accomplish is basicly to get a copy of the m_pShellFolder structure(the one it points at) to a new IShellFolder object..
I hope someone understood this
Cheers,
Henrik
|
|
|
|
|
You're doing exactly what you should be doing. Calling AddRef() tells the underlying COM object that there is a new reference to it. Just remember to call Release() through both pointers to properly clean up.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Does anybody know of any good examples of how to use Visual C++ to program an Add-In for the Visual Basic IDE? In VB, you'd add references to the MS Office and VB Extensibility models in the reference dialog, then add the line
Implements IDTExtensibility to your 'Connect' class. Fairly straight forward. How can I do this using Visual C++?
Thanks in advance for any help.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
there a book on ado in vc? (not vb)
|
|
|
|
|
Check out "Visual C++ 6 Database Programming Tutorial by Wendy Sarrett, ISBN 1861002416.
More detail on Wrox's website at http://www.wrox.com/Books/Book_Details.asp?sub_section=1&isbn=1861002416&subject=C%2B%2B%2FVC%2B%2B%2FC%23&subject_id=3
Hope this helps...
TEF
|
|
|
|
|
www.informit.com
online book called "Sams Teach Yourself Database programming with Visual C++ in 21 days" or something like that is available there...
Get ready for lots of cursing at those VB programmers with their full automation support...
couple of MSDN articles are essential here:
"Visual C++ ADO Programming" in ADO Appendices
"Using Visual C++ Extensions" in "
|
|
|
|