|
Hi
I had download one sample from Codeguru of Loading resource from .dll in main applications this is it's link :-
http://www.codeguru.com/Cpp/W-P/dll/article.php/c3637
In this sample Author has Made one MDI application in .dll and calling it's from Main application .In this .dll all resource in this .dll.
Now My question is How to Maintain Class information from .dll ? Because Like OnitDialog:: or OnMouseButton Event will included with dialog and dialog is in .dll But i dont' want to add events in .dll because it'll be same like .exe ...
I want to load only resource from .dll and for otherfucntion i want to add in main applications Because My project is Big ..So i want to add some directx function in Main application and resource will be .dll
So how can i do ?
thanx
|
|
|
|
|
I could really use some advice on how to implement a complex dialog I want to create.
Functionally, I would like an interface very similar to the new XP type MS common dialog FileOpen, even though it isn’t to be used for opening files.
Spy tells me that the FileOpen dialog has a couple of "Command Bars" a list control, and then some custom base class container.
As far as I know, the command bar approach requires docking the bar, which isn't easy to do in a dialog - you need a frame window to do that.
Here's what I would like to have in my dialog:
1) It should be a modal dialog.
2) The dialog should be resizable.
3) A vertical “command bar” type interface on the left with 5 main buttons. These should be drop targets so that the user can pick something from a listbox, drag and drop it onto one of the buttons. Looking as nice as the FileOpen control would be extra credit, but nice.
4) To the right of the command bar, I want to put a tree control and a list control in place, with a splitter between them. In one mode I might hide the tree window, but in other modes, I want them both to be visible and functional.
5) At top would be some controls, probably in a toolbar – a combo box is the main control needed.
6) At the bottom, similar controls as the common dialog – an edit box, and the OK/Cancel/Help buttons.
Again, my functional model seems a lot like the MS FileOpen dialog.
I’ve been working on this for some time, trying different tacks, and I’ve not yet succeeded in getting all the functionality I need.
For example, using articles from Code Project and Code Guru (thanks!) a resizable dialog with splitters and combos. I had problems getting the “control bar” working. I tried using bitmapped buttons, but was getting strange errors on redraw (they were owner drawn.) This is the route I’m still working on, but I’m not as happy with the “look” of the buttons, and was re-thinking the “control bar” approach.
I would welcome input! Thanks very much,
Gene Sewell
|
|
|
|
|
I'm writing some code to identify the class of CDialog controls.
I'm doing this within OnInitDialog().
My first hack at this is to loop through all of the children,
and do the following (Assuming children don't have children here):
CWnd* pChild = NULL;
pChild = (CWnd*)this->GetWindow(GW_CHILD);
....
while(pChild != NULL)
{
cName = pChild->GetRuntimeClass()->m_lpszClassName;
pChild = (CWnd*)pChild->GetNextWindow(GW_HWNDNEXT);
}
....
Ok, despite any errors in the code above, the code works and
loops through all of the children. The problem is that
"CTempWnd" is always returned. The reason this is a problem
is that it obscures the true identity of the control. I've
even tried using GetDlgItem(int nID). The return is always
"CTempWnd". I can't identify the class this way. Keep
in mind that I can access the control ID (IDOK/etc). If
there was some way of finding out the class by using the
dialog control ID, I'd do it.
Any help? In my dialog, in OnInitDialog(), I need to identify
all of the button controls (CButton). This is for the reason
that I want to Subclass them, though I don't know how many or
by what ID they carry.
Jon Wayne
|
|
|
|
|
Nevermind, did a search and found hte answer.
http://www.codeproject.com/script/comments/forums.asp?msg=514676&forumid=1647&XtraIDs=1647&searchkw=CTempWnd&sd=3%2F25%2F2003&ed=3%2F25%2F2004#xx517191xx
I don't know why CTempWnd was returned instead, although technically its true.
|
|
|
|
|
great !
if everybody could do so... and ask only interesting questions...
TOXCCT >>> GEII power
|
|
|
|
|
You are confusing MFC classes (e.g., CButton , CEdit , CDialog ) with Window classes (Button, Edit, #32770). The former is unknown at runtime, while the latter can be retrieved using GetClassName() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Load Resource's Bitmap To HBITMAP
I want to replace frame.LoadBmp("TextFrame.bmp") by frame.LoadBmp(IDB_BITMAP).
On other words,Original loaded picture by function "LoadImage", I want to load picture by Resouce's Bitmap.
HBITMAP hBitmap;//is member variable of CDibSection
hBitmap=uknownfunction(IDB_BITMAP)
How do I rewrite CDibSection::LoadBmp to Load Resource's Bitmap To HBITMAP?
PS:IDB_BITMAP is a Bitmap of Resoucre.
CDibSection frame;
////////////////
if (frame.LoadBmp("TextFrame.bmp")) {
HRGN h = frame.CreateRgn();
if (h)
SetWindowRgn(h, TRUE);
}
////////////////
// Loading BMP file
//
BOOL CDibSection::LoadBmp(const char *path)
{
Destroy();
hBitmap = (HBITMAP)::LoadImage(::GetModuleHandle(0), path, IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if (!hBitmap)
return FALSE;
DIBSECTION dib;
if (::GetObject(hBitmap, sizeof(DIBSECTION), &dib) != sizeof(DIBSECTION)) {
::DeleteObject(hBitmap);
hBitmap = 0;
return FALSE;
}
Header.Info = dib.dsBmih;
for (int i=0; i<3; i++)
Header.BitField[i] = dib.dsBitfields[i];
bytes_per_pixel = PixelBytes(dib.dsBmih.biBitCount);
bytes_per_line = ScanBytes(dib.dsBmih.biWidth, dib.dsBmih.biBitCount);
Bits = dib.dsBm.bmBits;
return TRUE;
}
|
|
|
|
|
I have an app using the CHtmlView to drive the user inteface.
I have a web page black.html, which is exactly that, a plain black page.
I have maximized the mainframe window but there is a 'very' thin white border around the 'right' and 'bottom' of the page. - How do i set this to black?
This is not an issue with margins etc in the web page. If i view the page in IE, the border disappears. It seems to be the Mainframe border.
I have tried:
Overriding OnEraseBkGround - for both CHtmlView + MainFrame
CBrush backBrush(RGB(0,0,0));
// Save old brush
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect); // Erase the area needed
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
PATCOPY);
pDC->SelectObject(pOldBrush);
I still can't get rid of the thin white border - please help
Carl
|
|
|
|
|
I have a rtf app bsed on CRichEditCtrl ( an dialog box based app) and i want to paste a CF_METAFILEPICT in my app.How can I do this?Can anyone help me?
Thanks a lot.
|
|
|
|
|
How to convert a CHAR which contain a number to a INT or WORD ?
|
|
|
|
|
If it's char data, then strtol should help.
Steve S
|
|
|
|
|
if you have ONE digit in the CHAR '7' or '9'
you can do this:
char cCharValue = '9';
int nValue = cCharValue-'0';
if it is a CHAR* (a string)
you must use
atoi()
|
|
|
|
|
All the responses below are correct, but if you want to be extra-nice about it, have a look Boost Lexical cast[^]
|
|
|
|
|
<br />
int num = atoi("65");<br />
<code> <br />
<br />
Pain is a weakness living the body
|
|
|
|
|
Hi,
I want to convert a CString to COleDateTime. I'm using COleDateTime::ParseDateTime()and passing it the string as _T("1/25/1996 8:30:00") which is a valid format acc. to MSDN. But still, it is not working.
Does anyone have any idea of what could be wrong or what setting do I need to change in my workspace (or on my system) to use COleDateTime properly?
Regards,
Pravin
|
|
|
|
|
Are you sure the regional settings for the date on your computer are set to 'MM/dd/yyyy' (or somethoing like that )??
This may be the source of the problem...
|
|
|
|
|
From my testing, ParseDateTime() does not care about the regional settings. I use dd-MMM-yyyy H:mm for mine and I can pass a dozen different formats to ParseDateTime() all yielding correct results.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I haven't used enums in C++ for a while and now I am using one, but I'm running into something that I don't get. I'm using my enum in a switch statment and I'm doing this
switch (m_eDataType) {
case VerifyType::Ticket :
valid = VerifyTicket ();
break;
} When I compile this it tells me that "Ticket" is not a value of VerifyType. If I take off the type and scope identifier and it works fine, but isn't what I have above a valid way to identify an enum value? I know in C# I could qualify an enum value with it's type, but I guess that's because in C# the enumerator type is a full fledged class. The enum is declared in my classes header file outside the class declaration.
Thanks.
- Aaron
|
|
|
|
|
No. I experienced this myself and found out that an enum in C++ does not declare a new named scope, and so shouldnt be preceded with the type name.
You could convert the enum into a class and have it work the C# way - the enum could be unamed within a class, or as static member variables.
|
|
|
|
|
I usually use enums and haven't seen any problem using it.
Please try the code below...
// ------------------------------------------
class MyClass
{
enum VerifyType {
Ticket = 1,
Money = 2
};
VerifyType m_eDataType;
bool valid;
public:
explicit MyClass(VerifyType const& type = Ticket)
: m_eDataType(type)
{
}
bool VerifyTicket() {
return (Ticket == m_eDataType);
}
bool CheckValidState() {
switch (m_eDataType)
{
case Ticket:
valid = VerifyTicket();
break;
case Money:
valid = false;
break;
}
return valid;
}
};
void main()
{
MyClass bar;
bar.CheckValidState();
}
// ------------------------------------------------
<b>Maxwell Chen</b>
|
|
|
|
|
This works for me:
class CMyClass
{
enum VerifyType {Ticket1, Ticket2, Ticket3};
void SomeFunction( VerifyType );
};
void CMyClass::SomeFunction( VerifyType vt )
{
switch (vt)
{
case Ticket1:
break;
case Ticket2:
break;
case Ticket3:
break;
}
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
That's how it's works for me to. The problem was that I couldn't qualify the enum value with the enum's name, for example VerifyType::Ticket1 , like I could do in C#. I guess I'll live with just the value though. Thanks for the replies everyone.
- Aaron
|
|
|
|
|
Hi,
[1]
I have a 3 way splitter which mimics the visual studio IDE.
I have augmented a debugging class (thanks ravi) and am using a CFormView for the bottom
debug window. Which is subclassed (The FormView has an edit control on it) so that debug messages are routed to it.
I have a global function dbg(char *s,...) in my main CWinApp override which finds the dbg class which is buried in the splitter and outputs info to that debug window.
However now I want to call it from anywhere in my src.
What I have done is declared it as
extern void dgb(char *s,...) in the .cpp CWinApp override.
Then to call it from anywhere I declare
extern void dgb(char *s,...)
in stdafx.h.
Then in my code I call
Dbg("test");
and it will call mydebugclass->print("test");
While this works and mimics the beahvior of the VS IDE how would I do this in a less hacky windows MFC fashion?
[2]
For each function in my debug class I have to add an extern for each function in there.
How do I avoid this? For example I may want to turn on my timing trace writes, or turn on
message box alerts where I have them defined etc.
[3]
How Do I pass in the current windows message so in my output I can mimic the MFC tracer?
I am trying to get configurable output e.g.
12:23:0023 CMyDerivedClass::OnInit() "my trace write" "Win32 Err = 0xFF"
and then I should be able to choose on the fly what trace inofrmation I would like to display.
Regards,
axe
|
|
|
|
|
I have a window with no non-client-area and some overriden parameters.
i need to popup the application menu when my simulation caption is clicked...
this does nothing:
<br />
SendMessage(WM_SYSCOMMAND, <br />
SC_MOUSEMENU+HTSYSMENU,<br />
MAKELPARAM(m_clientMenuPos.x, m_clientMenuPos.y));
The only way I can pop it up at the moment is :
<br />
CMenu* sysMenu = GetSystemMenu(false);<br />
int cmd = sysMenu->TrackPopupMenuEx(TPM_RETURNCMD, m_clientMenuPos.x, m_clientMenuPos.y, this, 0);<br />
if (cmd)<br />
SendMessage(WM_SYSCOMMAND, cmd);<br />
but this doesn't always bring the most updated menu.
Also, my application-menu contains only 'Move' and 'Close', what window-styles or overriden return-values do I need to have in-order to get all the other options ? (Maximize, minimize, restore, etc) [my window has WM_MAXIMIZEBOX for example).
|
|
|
|
|
For days,i study the subject of DLL, and I caught some problems in calling DLL as narrated bellow:
First one, in BCB,how to debug a program edited in Visual C++? Is it true that debugging the program I only call the .dll file used by LoadLibrary() and the functions called?
Second,when I debug a program in VC, calling the .dll file edited in Vc,I find out that the functions called have the same address (0x00000000) and the handle pointing to the .dll file have another address (0x00e10000) in called process. Why? At present,I narrate the calling form as following:
typedef int(*pMax)(int a,int b);
HINSTANCE hDLL;
PMax Max
HDLL=LoadLibrary("MyDll.dll");
Max=(pMax)GetProcAddress(hDLL,"Max");
A=Max(5,8);
Printf("比较的结果为%d ",a);
FreeLibrary(hDLL);//卸载MyDll.dll文件;
I don't know why the phenomenon brings about and hope someone can help me.Or contact me.
Thanks first.
dafan
|
|
|
|
|