|
In your main dialog class add a member variable of BOOL m_bShowImage. In your main dialog OnInitDialog initialize m_bShowImage to FALSE. In your main dialog OnBitmap method set m_bShowImage to not itself which will act as a toggle and call the secondary dialog Invalidate. In you OnPaint method for the second dialog where you originally had a string check for the file name replace that with the if (m_bShowImage == TRUE). Like below
class CImageDlg :CDialog
{
//...
public:
BOOL m_bShowImage;
};
BOOL CImageDlg::OnInitDialog()
{
//...
m_bmpBitmap.LoadBitmap(IDB_BITMAP2);
m_bShowImage = FALSE;
return TRUE;
}
void CImageDlg::OnBitmap()
{
// COMMENT out all other code.
m_bShowImage = !m_bShowImage; // Acts as toggle.
m_dlgImage.Invalidate();
}
void CImageDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// Get a pointer to the parent window
CImageDlg *pWnd = (CImageDlg *)GetParent();
// Do we have a valid pointer?
if (pWnd)
{
if (m_bShowImage)
ShowBitmap(&dc, pWnd);
}
}
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Well, thanks for your suggestion, I tried it and it works.
Now, can I bother you again? I hope I can……..(please…………… )
I’m sorry because I forgot to tell you that I what want is to have a bitmap shown after I input a code (in code named : m_strNumber) and I clicked a certain button which works as a trigger.
That’s why on the codes written in my previous letter I tried to load the image on the function : void CImageDlg::OnBitmap().
So my code looks like this:
void CImageDlg::OnBitmap()
{
// Load the image
UpdateData(TRUE);
if(m_strNumber=="001")
m_bmpBitmap.LoadBitmap(IDB_BITMAP1);
else if(m_strNumber=="002")
m_bmpBitmap.LoadBitmap(IDB_BITMAP2);
m_bShowImage = !m_bShowImage;
// Invalidate the second dialog window
m_dlgImage.Invalidate()
}
I have a strange result that if I input the number = 001, and then clicked the OK button, the bitmap is showing perfectly. But then, if I change the number to 002 and clicked the OK button without exiting my apps, my apps will results an error.
How did it happened, did I missed something again? Or do you have any other idea on how I can accomplish it.
Thanks again for your help.
Kathrin
|
|
|
|
|
I believe you'll get an assert if you call LoadBitmap withoutfirst freeing the bitmap that was there before. Can I ask why you're comparing a string instead of a number ? The best method IMHO for this sort of thing is an enum, because it means you can give each 'mode' a text name that makes sense to you but computationally it is fast because it is a number internally.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Some filename of files of specified folder(C:\ExUnder\Fx) have "_" of the name(ex; aa_b.txt, a_a_b.txt, _a.bmp).
I want to convert "_" to " ".
Namly, aa b.txt, a a b.txt, a.bmp.
Best regards.
|
|
|
|
|
first: Use the CString::Replace() for change the name of the file and
then use the CFile::Rename() function for change the file.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
please example !!
follow as bellow,
C:\ExUnder\Fx) have "_" of the name(ex; aa_b.txt, a_a_b.txt, _a.bmp, aa.bmp, ac-tt.bmp).
I really want to get the code using wildcard.
thank you very much.
mail : tomi34@hanmir.com
please, please !!
|
|
|
|
|
Perform a search using CFileFind, which excepts wild cards. And use the method described by Christian. It's all up to you. There is no magical Rename function that will do it for you.
|
|
|
|
|
Can anyone assist me I currently have a data-access layer written in VB and would like to port it over to C++ as I'm pretty sure there will be speed benefits in doing so...
This is the prototype of the function currently in VB:
Public Function RunSPReturnRS( ByVal sDSN As String, ByVal sSP As String, ParamArray params() As Variant) As ADODB.Recordset
I have no problems with the first two strings but can anyone give me the IDL and the function prototype to handle the ParamArray and returning the Recordset??? I have been able to find any good samples on these...
Many thanks,
William
|
|
|
|
|
William,
This should work for ya:
HRESULT RunSPReturnRS(
[in] BSTR sDSN,
[in] BSTR sSP,
[in, out] SAFEARRAY(VARIANT)* params,
[out, retval] _Recordset** );
You will also have to include the ADODB type library to compile in MIDL:
importlib("msado21.tlb");
Hope this helps
Richard Caetano
http://www.caetano.com/richard
---------------------------
Richard Caetano
richard@caetano.com
http://www.caetano.com/richard
|
|
|
|
|
Also I'd be curious to see how you're building that routine. It appears to be a routine to call stored procedures right?
Thanks!
Richard
---------------------------
Richard Caetano
richard@caetano.com
http://www.caetano.com/richard
|
|
|
|
|
Hello I was wondering if anyone out there has done any work with "waveform" functions? I have created and app the records, play's and pause's audio. Trying to get the audio to loop, seem to be having a little trouble specifying last chunck before loop starts again. MSDN say's to change the begin_loop and end_loop flags after prepareheader but before writing the chunck, this did not work for me set I set the flags before the prepareheader which worked but MSDN says that the flag param has to be zero for prepareheader to pass. Seems MSDN is incorrect. Does anyone have any knowledge in this area???
Help is ver appreciated.
Tracy
|
|
|
|
|
When I use the CMyAppDlg::m_hIcon icon the icon is big in the status bar... do I have to use a small or is there a code to make it small??
/*
BETA
*/
|
|
|
|
|
Rickard
unfortunately I do not have an answer for this, but a few observations that might help you to figure it out.
When you say the icon is big I assume that this is the 32 x 32 icon when you will be needing to display the 16 x 16 icon. CStatusBarCtrl::SetIcon doesn't seem to have any way to choose the icon size, and OnInitDialog uses CWnd::SetIcon to set the 32 x 32 and the 16 x 16 icon. CWnd::SetIcon returns a HICON so maybe if you create a member variable m_hSmallIcon and in OnInitDialog change the line to m_hSmallIcon = SetIcon(m_hIcon, FALSE) you can then use m_hSmallIcon in the call to CStatusBarCtrl::SetIcon.
Hope this helps.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
I'm trying to write a VB (yes, that's Visual Basic) Add-In using ATL. I've #import'ed MSO97.DLL and VB6EXT.OLB. Everything seems to compile fine, except for the following error:
error C2786: 'long (__stdcall *)(struct HWND__ *,void *,char *,struct _devicemodeA *,struct _devicemodeA *,unsigned long)' : invalid operand for __uuidof
This error refers to the following line, found in the created 'mso97.tlh' file:
_COM_SMARTPTR_TYPEDEF(DocumentProperties, __uuidof(DocumentProperties));
I've tried commenting out this line (since I have no intention of using DocumentProperties anyway), but it's re-inserted by the #import statement when I compile. If I remove the #import statement, and replace it with '#include "mso97.tlh"', then compiling fails miserably. Any ideas? I only desire access to the CommandBar and CommandBarControl interfaces.
Thanks in advance.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
OK, I noticed another thing. The GUID for DocumentProperties, as well as the DocumentProperties name itself, do not exist anywhere in my registry.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
Try specifying that you only want the interfaces and not all the extra junk. In VC++ it looks like this: #import "mso97.dll" raw_interfaces_only
I'm not sure how to do it in VB as I am strictly VC++.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hi all,
I want to know, can i make a report by Crystal Report 7.0 with deafult SQL query, that i'll can change the query in my program(run-time changing ...) ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
No...
Because the Crystal Report, take the fields from the General Query.
You can change the value of the parameter but not the query.
But you can make a Stored procedure that always returns the same fields, but this stored can make diferents querys depending the parameters, for example.
Good Luck!!!
Carlos Antollini.
|
|
|
|
|
Hi Carlos,
Yesterday, my friend said to me: "you can use of this: crystalreport1.sqlquery = "SELECT * FROM T1""
Of course, it is in VB ..
I want to know can i use of it in VC++ ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I am trying to start an exe app from a dll. I've used both WinExec(..) and CreateProcess(..) with no results. Is it at all possible to call an exe from a dll and if so, is there another way to do this? Please help me
Junior
|
|
|
|
|
Try the spawnxx famaily of calls
_spawnvp(_P_WAIT, tool, argv);
refer msdn.microsoft.com for exact desc.
|
|
|
|
|
CreateProcess should work, even from within a DLL. All you have to do is wait for the DLL's initialization process to finish before calling CreateProcess.
I'm willing to bet that you're setting the first parameter to the path\filename of the program you're running, too. Try combining the path\filename with your commandline parameters (if any) and pass the whole shooting match as the *2nd* parameter (make the 1st parameter NULL). Also, if you're using a CString to build the commandline, cast it to an LPCTSTR like so:
CString sMyCmdLine = "C:\myfolder\myprogram.exe /param1 /param2";
CreateProcess(NULL, (LPCTSTR)sMyCmdLine,....);
|
|
|
|
|
I had an eariler issue dealing with DAO access causing a program to crash. Apparently installing MDAC and DAOSDK solves that issue. (thanks to those who helped on this matter ) However now I am noticing a problem with COM, more specifically MSFLEXGRID. I have a MSFLEXGRID control in the program and I am noticing that within the main window it is not showing up and within a dialog box it is causing the program to crash long before it paints.
Are there more installs that need to happen?
I noticed this all worked when I had VC++ installed.
Thanks!
Chris
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
I would like to use ADO to keep database record in excel sheet. But I don't know how to do that. And the second step of my problem is of being able to compare value in the database to one given in a dialog box. In fact I'm building an automation which need to catch good value into a database according to a parameter given in my dialog box.
So if anybody could help me....
thanks
gerald
|
|
|
|
|
Througth a Excel ODBC Driver!!!
Good Luck!!
Carlos Antollini.
|
|
|
|