|
thanks you for reply..
Code is reformatted please check..
the DLL's code is written by my team member,I need to check with him..
but it is working properly for ImageHandle which is passed by reference in this function. It is causing problem with ButtonText & ButtonContent only...
|
|
|
|
|
Rahul Vaishnav wrote: Code is reformatted please check..
the DLL's code is written by my team member,I need to check with him..
but it is working properly for ImageHandle which is passed by reference in this function. It is causing problem with ButtonText & ButtonContent only...
Well, since the DLL 's source code is available you may debug the whole thing.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[Image resize DLL]
|
|
|
|
|
Ok I will debug it
Thank you very much for reply..
bye
|
|
|
|
|
Rahul Vaishnav wrote: ((PROCHICON)ProcButtonHicon)(&ImageHandle);
ButtonText =((PROCCSTRNAME)ProcButtonName)();
ButtonContent =((PROCCSTRCONT)ProcButtonContent)("1");
This is a very odd way of calling functions. Why not:
ProcButtonHicon(&ImageHandle);
ButtonText = ProcButtonName();
ButtonContent = ProcButtonContent("1"); Rahul Vaishnav wrote: if(hLib)
Redundant check.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I had a similar problem: Access violations caused by bad pointers after having freed a dll with FreeLibrary. Your problem sounds just the same.
The problem was, the dll and the exe each had its own copy of the c-runtime-library and each c-runtime-library had its own heap. Freeing the dll also freed its heap and all dynamically allocated memory.
To overcome this problem: Free memory where it had been allocated
Her is the link about the 'FreeLibrary problem' where i found the answer to the problem:
http://java.codeproject.com/Feature/SubtleBugs.aspx?fid=1647&msg=2660410
|
|
|
|
|
Thanks you for your reply..
I was on leave thats why I couldnt reply..?
I will go through this link..
Thanks you.
|
|
|
|
|
In the MSDN, it says below:
lpszIcon
Identifies an icon resource. This parameter can be either a null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro.
To load one of the standard system-defined icons, set the hInstance member to NULL and set lpszIcon to one of the values listed with the LoadIcon function.
This member is ignored if the dwStyle member does not specify the MB_USERICON flag.
MSGBOXPARAMS msgparam = {0};
msgparam.cbSize = sizeof(MSGBOXPARAMS);
msgparam.hwndOwner = NULL;
msgparam.lpszText = _T("text");
msgparam.lpszCaption = _T("caption");
msgparam.dwStyle = MB_USERICON | MB_OK;
msgparam.hInstance = NULL;
msgparam.lpszIcon = ::LoadIcon(NULL, IDI_WINLOGO); <font color="blue">I want to use as the MSDN says.Actually I know it will compile error.</font>
::MessageBoxIndirect(&msgparam);
<pre>
|
|
|
|
|
What is the problem ? What is your question in fact ?
Di you have a compilation error ? If yes, why don't you simply put the exact error message so we can try to help you ?
|
|
|
|
|
//msgparam.lpszIcon = ::LoadIcon(NULL, IDI_WINLOGO);
msgparam.lpszIcon = MAKEINTRESOURCE(IDI_WINLOGO);
The MSDN has fooled me, or I misunderstand the MSDN words, I should just use MAKEINTRESOURCE, not using ::LoadIcon.
|
|
|
|
|
msgparam.lpszIcon = (LPCTSTR)::LoadIcon(NULL, IDI_WINLOGO);
[added]
BTW: see here [^].
[/added]
[added]
BTW2: Xing Chen's solution [^] actually works.
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, August 1, 2008 3:52 AM
|
|
|
|
|
set lpszIcon to one of the values listed with the LoadIcon function means:
lpszIcon can be one of these value:
IDI_APPLICATION
IDI_ASTERISK
IDI_ERROR
IDI_EXCLAMATION
IDI_HAND
IDI_INFORMATION
IDI_QUESTION
IDI_WARNING
IDI_WINLOGO
so you can use them directly.
msgparam.lpszIcon = IDI_WINLOGO;
|
|
|
|
|
Hello,
I made a dll that has a bunch of functions called from a console application. One of them creates a CFrameWnd window. Inside the function that creates my CFrameWnd, I can create a CToolBar object. However I now want the user of the dll (the creator of the console application) to be able to attach a customized CToolBar object to that window (instead of the default CToolBar object that I created during window creation inside the dll). So I thought I simply create the customized CToolBar object in the client application (console application) in the same way I did in the dll function. That however does not seem to work: in release mode the toolbar appears, but doesn't have any bitmap, in debug mode, I get debug assertion errors because of unexisting resource or instance handles.
Following few lines in my console application are impossible to execute without assertion errors in debug mode:
CToolBar* toolBar=new CToolBar();
toolBar->CreateEx((CFrameWnd*)dllFunctionGetFrameWnd(),TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_SIZE_DYNAMIC|CBRS_TOP|WS_CLIPCHILDREN|WS_CLIPSIBLINGS);
toolBar->LoadToolBar(IDR_TOOLBAR1);
toolBar->SetWindowText("Toolbar");
toolBar->EnableDocking(CBRS_ALIGN_TOP);
Anyone knows a workaround? Or can anyone propose an alternative solution to my problem?
|
|
|
|
|
FloatingMarc wrote: a bunch of functions called from a console application. One of them creates a CFrameWnd window
You need to look at the assertions and the code where they occur.
You should see what's going wrong.
You need to make sure you're making the right kind of DLL if
you're using MFC in a DLL. All the info you need to do this
can be found here: Kinds ofDLLs[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hai all
Just i want to develop a apllication that track the amount of data transferred while I am on net, both sent and recieved. It will also keep monthly records on each time log-in basis, so that I can get my usage data.
If You have any Ideas pleas share with me
Thanks & Regards
Vicky000000
|
|
|
|
|
|
vicky00000 wrote: ...track the amount of data transferred while I am on net, both sent and recieved.
Have you looked here?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Dear all
how to save an excel file instead of .txt file in c++? anyone has such code or suggestion?thanks a lot
gentleguy
|
|
|
|
|
Excel.Application COM may be solve your problem.
Emimmortal
|
|
|
|
|
Try using the *.csv fileformat. (comma separated values). It is still a text file but can very easily be generated and imported into excel
|
|
|
|
|
My goal:
when user click on the 'close' red check button on the right top most dialog, I want to hide the main dialog of the app, show an icon in the tray(these codes work fine, not showing).
My codes are below, It exits the app anyway.
BOOL CMyVIPTestDlg::PreTranslateMessage(MSG* pMsgIn)
{
if (pMsgIn->message == WM_SYSCOMMAND)
{
if (pMsgIn->wParam == SC_CLOSE)
{
this->ShowWindow(FALSE);
return TRUE;
}
}
BOOL bRet = CDialog::PreTranslateMessage(pMsgIn);
return bRet;
}
|
|
|
|
|
If you're using MFC, why not respond to the message the MFC way?
ON_WM_SYSCOMMAND()
void CMyVIPTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if (nID == SC_CLOSE)
{
ShowWindow(SW_HIDE);
return;
}
CMyDialog::OnSysCommand(nID, lParam);
}
That works fine for me - I just tested it.
It's always curious to me how often the PreTranslateMessage() method is misused.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your reply.
Acctually, I think the PreTranslateMessage is the most misusable method.
When don't know where to handle the message, the first place to place the code is the PreTranslateMessage.
|
|
|
|
|
fantasy1215 wrote: When don't know where to handle the message, the first place to place the code is the PreTranslateMessage.
That's why it's a good idea to know how to use the documentation.
All the MFC message map macros for WM_ window messages start with
"ON_WM_". If the message map macro doesn't exist for a given message,
there's always ON_MESSAGE, which will handle any message.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I was wondering if someone could clear this up for me.
Consider the below statement:
<br />
#define randomise(i) rand() % (i)<br />
The way I see this, both randomise and rand are functions.
But a search online made me think randomise could also be deemed a macro.
Is randomise, in computer science terms, a function or a macro (or both)?
Cheers,
|
|
|
|
|
randomize is a macro.
rand is a function in the CRT library, but in the code you've shown,
it's just a token used during expansion of the randomize macro by the
pre-processor.
The VC/VC++ docs call your randomize macro a "function-like macro".
That's my take on it
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|