|
I've created 2 classes each with it's own dialog box in an MDI application
1. commanding class
2. picViewer class
the commanding class has a func load().
where i create a picViewer variable.
<br />
void commanding::load()<br />
{<br />
UpdateData (TRUE);<br />
<br />
FILE *pic, *pic1, *pic2;<br />
picViewer cam1; <br />
pic = fopen("C:\\cv\\16bit.jp2", "rb");<br />
pic1 = fopen("C:\\cv\\nature_50.jp2", "rb");<br />
pic2 = fopen("C:\\cv\\8_8.jp2", "rb");<br />
unsigned int numRead;<br />
<br />
int i = 0;<br />
while(i < 3)<br />
{<br />
if(i == 0)<br />
numRead = fread(buff, sizeof(BYTE), 100000, pic);<br />
else if(i == 1)<br />
numRead = fread(buff, sizeof(BYTE), 100000, pic1);<br />
else<br />
numRead = fread(buff, sizeof(BYTE), 100000, pic2);<br />
cam1.showPicture(buff,numRead);<br />
i++;<br />
Sleep(2000);<br />
}<br />
<br />
fclose(pic);<br />
fclose(pic1);<br />
fclose(pic2);<br />
UpdateData (FALSE);<br />
}<br />
<br /> the picViewer class has a func show().
<br />
void picViewer::show(BYTE bfr[], DWORD size)<br />
{<br />
HBITMAP m_bitmap = NULL;<br />
CImage image;<br />
CJpeg2kDecoder imDec;<br />
<br />
image = imDec.Open(bfr, size);<br />
m_bitmap = (HBITMAP)image;<br />
m_nCam1img.SetBitmap(m_bitmap); <br />
}<br />
whenever I run the application i open up both dialog boxes hit run on the commanding dialog box i get an error when i get to "m_nCam1img.SetBitmap(m_bitmap); " which points to:
<br />
_AFXWIN_INLINE HBITMAP CStatic::SetBitmap(HBITMAP hBitmap)<br />
{ ASSERT(::IsWindow(m_hWnd)); return (HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap); }<br />
in afxwin2.inl
what does that mean? what am i doing wrong? what would i need to do in order to show a picture in a separate dialog box?
thanks!
Kitty5
|
|
|
|
|
kitty5 wrote: picViewer cam1;
If picViewer is a window or dialog it is never being created therefore the CStatic child window is also never created so IsWindow(m_hWnd) returns false and Asserts during debugging.
led mike
|
|
|
|
|
led mike wrote: kitty5 wrote:
picViewer cam1;
If picViewer is a window or dialog it is never being created therefore the CStatic child window is also never created so IsWindow(m_hWnd) returns false and Asserts during debugging.
picViewer is the class that is related to the picViewer dialog.
I added both
<br />
cam1.Create(IDD_PICVIEWER,0); <br />
cam1.EnableWindow(TRUE);<br />
to my commanding::load() function.
this stops the crashing.
however, no picture is shown in the picViewer dialog box even though i call the show().
<br />
cam1.show(buff,numRead);<br />
Thanks!
-- modified at 14:35 Thursday 1st February, 2007
Kitty5
|
|
|
|
|
kitty5 wrote: picViewer is the class that is related to the picViewer dialog.
I don't know that that means.
In the first code you posted:
void commanding::load()
{
UpdateData (TRUE);
FILE *pic, *pic1, *pic2;
picViewer cam1;
that instance of picViewer is local to that function so it is not related to anything else.
led mike
|
|
|
|
|
led mike wrote: In the first code you posted:
void commanding::load(){UpdateData (TRUE);FILE *pic, *pic1, *pic2;picViewer cam1;
that instance of picViewer is local to that function so it is not related to anything else.
oh... really?!
hmmm. ok then ummm... how would i be able to open up an instance of the picViewer dialog box in the commanding class and be able to update the bitmaps?
i've changed my commanding to:
<br />
int commanding::loadCmdGet3CamData()<br />
{<br />
UpdateData (TRUE);<br />
<br />
FILE *pic, *pic1, *pic2;<br />
picViewer cam1;<br />
pic = fopen("C:\\cv\\16bit.jp2", "rb");<br />
pic1 = fopen("C:\\cv\\nature_50.jp2", "rb");<br />
pic2 = fopen("C:\\cv\\8_8.jp2", "rb");<br />
unsigned int numRead;<br />
cam1.Create(IDD_IMAGEVIEWER,0);<br />
cam1.EnableWindow(TRUE);<br />
int i = 0;<br />
while(i < 3)<br />
{<br />
if(i == 0)<br />
numRead = fread(buff, sizeof(BYTE), 100000, pic);<br />
else if(i == 1)<br />
numRead = fread(buff, sizeof(BYTE), 100000, pic1);<br />
else<br />
numRead = fread(buff, sizeof(BYTE), 100000, pic2);<br />
cam1.showPicture(buff,numRead);<br />
i++;<br />
Sleep(2000);<br />
}<br />
<br />
fclose(pic);<br />
fclose(pic1);<br />
fclose(pic2);<br />
}<br />
thanks,
Kitty5
|
|
|
|
|
What you have posted so far indicates that you lack the basic knowledge required to achieve your goal on purpose. So changing things and trying it might work eventually if you get lucky. There are several good books, there are also some decent sample applications and tutorials available with Visual Studio and/or on msdn.microsoft.com that might help in regards to the fundamental concepts that you are missing. I don't know that I would be capable of providing adequate coverage in a forum.
led mike
|
|
|
|
|
I agree with led mike's response.
I see a misunderstanding of variable scope in your code.
Here's my reply to your other related post:
In your picViewer::show() method:
Your CImage object goes out of scope at the end of the function so it probably destroys the
HBITMAP via its destructor.
Instead of
m_bitmap = (HBITMAP)image;
try
m_bitmap = image.Detach();
and remove this line:
if (m_bitmap) DeleteObject(m_bitmap);
Same with code above: All your variables are local so they no longer exist when the function
ends.
Mark
|
|
|
|
|
Is m_nCam1img on same dialog and when you run m_nCam1img.SetBitmap(m_bitmap); and Is m_nCam1img valid and aslo if you want to load a jpg file you can use of (CImage)
|
|
|
|
|
Hi everyone.
thanks for responding it's been really helpful.
with much reading i figured it out and it all makes sense now.
I added this to my commanding::load():
<br />
ImageViewer *imgViewDlg;<br />
imgViewDlg = new ImageViewer();<br />
imgViewDlg->Create(IDD_IMAGEVIEWER, NULL);<br />
imgViewDlg->SetWindowPos(NULL, 0, 0, 700, 700,SWP_NOMOVE); <br />
imgViewDlg->ShowWindow(SW_SHOW);<br />
& then I call the showImage()
<br />
imgViewDlg->showPicture(buff,numRead);<br />
and this seems like it is working.
now i'm just looking to see if there's a function for "isWindowActive" or something that i can check if the particular dialog box is inactive because I don't nessesarily want to keep updating the pictures if the window is in the background and someother window is on top of it.
thanks!
Kitty5
|
|
|
|
|
|
Good Morning Everyone,
I am using Visual C++ 6.0 MFC. I am writing my first multi-threaded application and I need to be able to use semaphores. In examples that I have looked at they say to declare the semaphore class as CSemaphore cph(1, 2) for example. When I try to declare the semaphore in my class header file the compiler returns with the type of error that you would get if you did not #include a needed header file. Is there a header file that CSemaphore requires to be #included?
Thanks,
Buck
|
|
|
|
|
BuckBrown wrote: Is there a header file that CSemaphore requires to be #included?
They hide that information in the documentation[^]
led mike
|
|
|
|
|
I guess I really don't understand. I read this documentation earlier and thought the idea was something like this -
class CTests : public CWnd
{
// Construction
public:
CTests();
CTemperature* pTemperature;
COutput* pOutput;
CGPIB* pGPIB;
CTabPageSSL* pTabPage;
CSemaphore cph(1, 5);
// Attributes
private:
If I remark out the declaration it compiles fine, if not it does not compile.
Buck
|
|
|
|
|
BuckBrown wrote: I read this documentation earlier
maybe your definition of "reading" is different than mine.
From the documentation:
Requirements
Header: afxmt.h
led mike
|
|
|
|
|
Gee, do I feel stupid now. I was so focused on the body of the document that I didn't even notice the little requirements section. My appologies.
Thanks
|
|
|
|
|
BuckBrown wrote: class CTests : public CWnd
{
// Construction
public:
CTests();
CTemperature* pTemperature;
COutput* pOutput;
CGPIB* pGPIB;
CTabPageSSL* pTabPage;
CSemaphore cph(1, 5);
Doing that in the header file won't compile. The overloaded constructor should be invoked using the constructor of your CTests class:
<code>CTests::CTests() : cph(1, 5) {
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Boy that's the truth. That's why I became a microelectronics engineer in the integrated circuit industry (I help develop the silicon that makes us feel stupid).
Thanks for the input
Buck
|
|
|
|
|
Hello,
I am playing around with a DVD-Video API sample which is parently is available online.
When I compile it, it appears that I am a "X11/Xlib.h" file missing. Can anyone tell me where I can get this file, please?
Thank you...
Khoramdin
|
|
|
|
|
do you really have the Xlib.h file somewhere, because if the compiler doesn't find it, it is either because the file doesn't exist or it's not in his includes...
|
|
|
|
|
Your program is probably from Linux and is using X11 to display its GUI.
You have several options:
Install an X-server on your machine and use it to display your sample program.
Not for the faint of heart.
Convert your program to use another gui.
Much work, but a good exercise.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
If you are referring to the project I made and sent to you then you need to set up your Visual
Studio environment...
Follow these steps first: Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK[^]
Repeat step 3 from that article using the paths to the DirectX SDK include and lib folders. On my
machine they are here:
C:\Program Files\Microsoft DirectX SDK (December 2005)\Lib
C:\Program Files\Microsoft DirectX SDK (December 2005)\Include
You'll also need to add an include-files path to the DirectShow base classes - On my machine it's
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\BaseClasses
I built the DirectShow base classes library and included it in the lib folder of the project.
They are UNICODE builds, one is debug and one is release build.
I test-built the project and it builds/runs so it should work for you once you have VS set up
properly.
If this XLib.h file is a *nix issue I can't help you there - it's a Windows app
Mark
|
|
|
|
|
Hello Mark,
Thanx for the reply. I was trying your stuff when I started to get the error. Funny enough I had downloaded and installed few SDKs but not the "Microsoft Platform SDK for Windows Server 2003 R2". I just thought that has got to do with Server stuff.
I am going to get the Microsoft Platform SDK for Windows Server 2003 R2. Most probably my problem is exactly what you mentioned in your message.
Thanx again,
Khoramdin
|
|
|
|
|
Khoramdin wrote: but not the "Microsoft Platform SDK for Windows Server 2003 R2". I just thought that has got to do with Server stuff.
That's the current version that it supports - It includes backward-compatible info/files for all
previous versions of Windows as well.
You'll want to get it - besides for the latest headers/libraries, it's the most recent
documentation.
Keep in mind also that using VS Express has limitations. There's no resource editor, limited
help files, no MFC, etc. *EDIT* No Spy++
Mark
-- modified at 17:43 Thursday 1st February, 2007
|
|
|
|
|
Hello Mark,
I see your point. I guess I will get the Visual Studio 2005 Professional Edition.
I noticed it has other editions which seems far tooooooo profesional. well, they sound like it at least. What I mean by that is the ones called:
Visual Studio 2005 Team Suite
Visual Studio 2005 Team Foundation Server
Visual Studio 2005 Team Edition for Database Professional
The lis goes on but I decided to stop.
Thanx again for your help, mate.
Khoramdin
|
|
|
|
|
Hi Everybody,
While working on VC++ IDE we always feel pain on configuring VC++ directory settings for a new project which uses various 3rd components or includes various levels of folders as included folders in the project .
I have developed a VC++ Directory Utility which can help a VC++ developer in following ways ::
(1) It works for VC++ 6.0 , 7.1(2003) & 8.0 (2005)
(2) SAVE::You can save the existing settings in a suitable list and use it further. You can save Directory setting for other computer user users and use it for your own purpose.
(3)APPLY :: This will show you all saved list . You can apply the saved Dir Settings for your running IDE.
(4) MERGE :: You can merge two existing settings and work on two projects together.
(5) CONVERT :: You can convert Directory setting for one verion of VC++ to the other .
(6) EDIT :: Edit feature is more enhanced as at one shot you can recursively select all the directories of selected folder . You can even Replace certain text by some other text .
I am keen to know if there already exist such type of Software . IF anybody interested to use this I can send it to him . Please send me a mail for that.
REgards
Avanish
Avanish Kumar
GE IIC, HUDA LANE , S P Road ,
Secunderabad -20003(INDIA)
Avanish.Kumar@ge.com
Kumar.Avanish@yahoo.com
|
|
|
|