|
Did you call AfxSetResourceHandle() to tell the framework you are using an external resource dll?
If not, load the dll with LoadLibrary() and then pass the handle to AfxSetResourceHandle() in your InitInstance override.
If you are already doing it, I don't know what's the problem.
Cheers,
Paolo.
|
|
|
|
|
Hello Paolo,
thank you for your time.
I got this code from MSDN, which should do the job:
m_hInstDLL = ::LoadLibrary("ExtRes.dll");
if ( !m_hInstDLL )
{
return FALSE; // failed to load the localized resources
}
else
{
AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL
}
As I wrote, it works with simple elements, it only fails with custom controls and ActiveX-controls.
Must I tell the DLL that it has to use these? Or the App, that the DLL uses it? HOW???
Martin
|
|
|
|
|
Hi Martin,
I'm sorry, but I can't tell you more. I never tried to use a resource DLL.
I also saw your previous message "difference of custom controls from NT to 9x". I replied just to be sure you was using the 'recommended' method.
When I have some time, I will do an experiment.
As for now, maybe you will have better luck with more experienced programmers. I hope
Cheers,
Paolo.
|
|
|
|
|
Only a few questions:
What do you mean with "custom controls"?
I suppose you have a static control (or some other standard control) in your dialog resource that gets subclassed later in the code, so why is that dialog different from the others?
And if you create a custom control at run-time, then you should have no problems at all, right?
How are the custom controls implemented in the code?
I have no other ideas...
Paolo
|
|
|
|
|
The AfxSetResourceHandle() only sets the resources for the current module.
If the custom controls and Active-X are in another DLL, then you need to create your resource DLL as an MFC Extension DLL, then it will get added to the CDynLinkLibrary list of DLL that will be searched for additional resources.
If you visually trace through the code that loads dialog resource templates, or even the CString LoadString member function, you will see examples of this internal CDynLinkLibrary list in use.
|
|
|
|
|
CustomControl
is that icon on the tool bar of the dialog editor with the
human head on it. <g> no pun intended.
Martine I usually get this kind of promlem when I forget to Register my custom window class.
But I don't know why it does not work on win 98. is it diffrent
|
|
|
|
|
Hi there, thank you very much for your help!
You've led me to the right path.
The LoadLibrary etc. is alright, the problem was the external resource DLL in conjunction with a custom control.
I have to register the window class of the control with the WNDCLASS-structure.
One element of this is the hInst, which most of the controls (Grid, BitmapViewer etc.) fill with AfxGetInstanceHandle(), which is okay in most cases.
But: here I needed AfxGetResourceHandle(), as I have to register the control with the resource DLL!!!
I still don't know why it worked with NT, but...
Greetings, Martin ))))
|
|
|
|
|
Hi,
looking for CodeWright forum.........can any1 help?
tnx
Yaron
|
|
|
|
|
Hi Yaron,
At first glance, strange to see something about CodeWright here on this site. But this proves still a lot of people ar using this powerful and extremely adaptable editor.
In the past, I've asked the guys at StarBase (formerly known as Premia Corporation), if there was somewhere a CodeWright forum. But unfortunately, so far, it doesn't seems to exist, at least not under their 'wings'. I could have used such a forum myself also very well in the past, but I always had to find the solution myself (which is highly interesting, but sometimes also heavily time consuming... ).
Anyhow, can you more specific tell us what you're looking for? Perhaps other people, who are heavily using CodeWright, can help you.
Regards,
Geert
|
|
|
|
|
Hi Geert,
tnx a lot for your reply, happy that an other person is looking for codewright help/forums......
let me specify my problem :
I've wrote a console application using win32 API, I want to add it to codewright.
I've added an icon in the tool-bar, now what I want is , when pressing the icon , a text box will be opened, and the user will be able to type in several arguments.then I want to run my console application in output->shell window using these arguments.
I don't know how to do the above, I've tried to look in help with no success.
can you help???
tnx again,
Yaron
|
|
|
|
|
Yaron,
Here is an AppBasic Macro that will do what you want. Create a file in Codewright, paste in the code below and then save it with filename of yourfile.cwb. To use it goto app basic tab and open the file. To use it press the run button. Then goto the API command dialog and type 'ExecMyUtil' (no quotes) and hit enter. It will then prompt you for an address to ping and it will then ping that address in the shell window. Once you see it works you can modify the code to ask for the parameters you would like and then Execute the command. To use the macro from a toolbar just use the function name directly. To load the cwb file so you do not need to every time you start codewright, goto the to Tools - Appbasic Macros - Load Macros menu item and in the lower section of the dialog that appears click add and then find the cwb file you created and then just click OK, now the macro will be loaded (but will no show in the AppBasic window) and be available for your toolbar.
Chris
**start of code**
Attribute VB_Name = "ExecMyUtil"
Private Sub ExecMyUtil()
Dim FunctionToExec As String
Dim Param1 As String
Param1 = InputBox("Please enter address to ping")
If Len(Param1) = 0 Then
Exit Sub
End If
LibPreLoad "cwdosbox" 'Make sure Shell window is in place
If LibFunctionExists("DosBoxExec") Then
FunctionToExec = "DosBoxExec 'ping " & Param1 & "'"
LibFunctionExec "DosBoxCurrent" ' Make Shell tab Current
LibFunctionExec FunctionToExec
Else
MsgBox "Error Loading Shell Window"
End If
End Sub
'{{CWBASIC_LOADERINFO
' cwbAddHandler 'Private Sub ExecMyUtil()', '%F'
'}}CWBASIC_LOADERINFO
**end of code**
|
|
|
|
|
Hello,
I've written a server socket class and it is defined as a member of a dialog (dialog based app)
example:
class CPortmonDlg : public CDialog {
public:
CPortmonDlg(CWnd* pParent = NULL); ServerSocket m_serversock;
...
In ServerSocket there is a method that captures server responses. How do I perform an InsertString to a list box that is on the CPortmonDlg dialog ?
Thanks,
Tony
|
|
|
|
|
Add a member variable in your CServerSocket derived class that refers to your dialog, then use it to access the listbox.
<br />
class ServerSocket {<br />
public:<br />
CPortmonDlg* m_pDlg;<br />
...<br />
}
Initialize the pointer in your CPortmonDlg constructor or OnInitDialog (before activating the socket) this way:
<br />
CPortmonDlg::OnInitDialog()<br />
{<br />
m_serversock.m_pDlg = this;<br />
...<br />
}
Then you may use the pointer to access a member listbox, in your ServerSocket class:
<br />
m_pDlg->m_listbox.AddString();<br />
This is just a way of doing it.
Cheers,
Paolo
|
|
|
|
|
Paolo,
Much thanks, Works as you said!
Tony
|
|
|
|
|
Hi,
I have an old program (with source code) which uses DDE to communicate. Can I use a new or better technique instead of DDE?
|
|
|
|
|
OLE is an improved version of DDE and ActiveX is an improved version of OLE. OLE and ActiveX can be quite complicated but the Automation part can be surprisingly easy. You probably can convert the program to be an Automation server. I do not know what examples there are in this web site and others but I am sure there are many examples. Just look for the Automation part and generally ignore the other types of OLE and ActiveX. An Automation object is what you get when you do a VB CreateObject.
|
|
|
|
|
I have implemented the MFC CRichEditView class, which is a CRichEditCtrl wrapped in a CScrollView. MFC provides a lot of functionality for character and paragraph formatting but they fall off the edge of the earth with respect to printing---setting margins, formatting to margins, pagination, etc. I would expect that something as simple as setting page margins would be straightforward, but I have found no documentation for any of this. There is one obscure MFC sample written in C, which I found pretty useless! This has to be an intentional deletion on Microsoft's end because, what good is all the wonderful formatting functionality they provide if I can't print anything?
Does anyone have ideas about how to print the CRichEditView?
Thanks
Mike Newberry
|
|
|
|
|
Hello to all fellow programmers
Like the title says... What's the best method to get a CPropertySheet pointer from within a CPropertyPage ?
Thanx in advance for any help and have a nice day !
|
|
|
|
|
I guess you may use a simple GetParent(), because the pages are children of the property sheet and not of the tab control.
The best way to know is trying
Cheers,
Paolo.
|
|
|
|
|
Paolo is right, but you'll need to cast the return from GetParent() to a CPropertySheet*. So you'd do this in your CPropertyPage-derived class:
CPropertySheet* pSheet = (CPropertySheet*) GetParent();
If you need to access memebers of your CPropertySheet-derived class, just replace CPropertySheet in the code above with the name of your derived class.
|
|
|
|
|
G'day Luc,
Something that I do quite frequently when dealing with property sheets is to create a base class for the property pages - say CBasePropertyPage - and add member functions to access the parent property sheet.
I.e
CMyPropertySheet* CBasePropertyPage::GetPropSheet()
{
return (CMyPropertySheet*)GetParent();
}
I also add member functions to access data that is stored or managed by the property sheet.
I.e.
CMyDataClass* CBasePropertyPage::GetDataPtr()
{
return GetPropSheet()->m_pDataPtr;
}
I then derive my property pages from this class.
This gives *all* of the property pages easy access to the parent property sheet and any data that it maintains.
Hope this helps.
Steve
|
|
|
|
|
Good
Thanx for everyone who gave me an answer
It's fun to have such a good support from anyone in the world
Have a nice day !
|
|
|
|
|
Dear All,
Can anyone tell that how can one enable/disable the tray menu items? If EnableMenuItem() can be used for this purpose then how?
Thanks in advance,
Regards,
Atif
|
|
|
|
|
Hi,
I need to Bold the text on the property page tab when the page is active.
I have been successful in setting all the tabs to bold with the
following Code:
BOOL CPropSheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
// Set the attributes of the font.
LOGFONT logFont;
memset(&logFont, 0, sizeof(LOGFONT));
logFont.lfWeight = FW_BOLD;
// create the new font.
CFont font;
font.CreateFontIndirect(&logFont);
// set the control to use the new font.
CTabCtrl* pTabCtrl = GetTabControl();
pTabCtrl->SetFont(&font);
return bResult;
}
I have placed the code in the OnSetActive() event for the Pages
but I can't seem to get the handle to the sheet to use the
GetTabControl() function.
If anyone has any ideas on how to do this or can provide a
sample application it would be greatly appreciated.
TIA,
Lori
|
|
|
|
|
From any of the pages, you can get a pointer to the sheet with:
CPropSheet* pSheet = (CPropSheet*) GetParent();
However your code has another bug. You have the font variable on the stack, so as soon as the function returns, font gets destroyed, taking the GDI font object with it. Make the CFont variable a member variable of the sheet so it will be available for the lifetime of the sheet.
|
|
|
|