|
Hi
In vc++ 6.0 , i want to know how to create a Menu Bar Button in Form View SDI (as File,Edit,Help) at run time through code.
thanks
regards
shakumar
shakumar
|
|
|
|
|
shakumar_22 wrote: In vc++ 6.0 , i want to know how to create a Menu Bar Button in Form View SDI (as File,Edit,Help) at run time through code.
Get the pointer of Menu using GetMenu api, than extract teh particular menu by using GetSubMenu api, and on pointer of returned Menu class as the new button!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
|
Hi,
I am reading the jpeg image and writing the data to the text file(as binary). I want to reconstruct the jpeg image (like BMP) using the data written in text file. And I want to display it on dialog. Is it possible..?? If Yes let me know the procedure.
Thanx in advance.
Reagards
Shiva
|
|
|
|
|
Did you have a look at GDI+ look here [^]
Regards,
Sandip.
|
|
|
|
|
Do you want to show jpeg file so you can use of CImage class.
|
|
|
|
|
Hi all,
I m using a tree ctrl ,Here i m create diffrent Parents and its Child.
I m using checkbox funcnality here.
I want if i check the parents's check box then all child of selected parent is also checked.
Please anyone can tell me how can i do this.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello and good day. I have 2 applications wherein I want the 1st which creates a graph send its image to the 2nd which will display it. I searched for some ways and ended up using a MFC shared DLL wherein I have a HBITMAP which the 1st one will write image on, and the 2nd one will read (using WM_COPYDATA for signalling, and mutex for synch). It's declared as the ff:
#pragma bss_seg("MFCDLLSample")
TESTDLL_API HBITMAP DLLImageBmp;
#pragma bss_seg()
Now, I checked first if it works by having the 1st app make a graph then display it on another picture box (same app) and it actually worked. When I tried to display it in the 2nd, it does not display. I coded it like this in the 2nd app:
PicWnd = GetDlgItem(IDC_PICBOX);
PicDC = PicWnd->GetDC();
oldBmp = (HBITMAP)PicDC->SelectObject(DLLImageBmp);
PicPaintDC.BitBlt(0, 0, 404, 404, PicDC, 0, 0, SRCCOPY);
CDialog::OnPaint();
Can anyone help me out with this? I really need to know what might be wrong with my code or implementation.
Thank you in advance for the help and time!
--added contents:
I forgot, TESTDLL_API's definition is this:
#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif
Thanks again!
modified on Monday, June 23, 2008 12:48 AM
|
|
|
|
|
GDI handles cannot be shared across process.
You have to think of some alternative methods to transfer the image from the first process to next. A possible method is sending the pixel data of the bitmap to the second process and the second process should recreate the bitmap using the pixel data.
1) you can use GetDIBits() function to get the pixel data of a bitmap
2) use WM_COPYDATA or other interprocess communication methods to send the pixel data to the second process.
3. use CreateDIBitmap() function to recreate the bitmap.
|
|
|
|
|
Naveen wrote: GDI handles cannot be shared across process.
Yes, but if it was shared through DLL, its still not possible? I was adviced last time to do that. Please refer to this link[^].
|
|
|
|
|
Llasus wrote: I was adviced last time to do that. Please refer to this link[^].
I am also confused seeing that.
AFAIK, it cannot be shared.
From MSDN:
"GDI objects support only one handle per object. Handles to GDI objects are private to a process. That is, only the process that created the GDI object can use the object handle"
The GDI handles are actually offset to the handle map's that reside in the client side. So when you pass a handle to another process, it simply points to a location in the handle table in that process. Some times, the object in that location will be entirly a different one such as Brush or Pen or some times the object itself is not created. So the result will be unpredictable.
if you want to know more please read the article Give Me a Handle, and I'll Show You an Object[^]
|
|
|
|
|
Naveen wrote: I am also confused seeing that. [Confused]
Guess I trusted that advice too early, even though I had a doubt in my mind if it was possible in the first place.
Anyway, I'll read the article to have more knowledge on this and try coding the solution that you gave me earlier on. Thank you very much for your help and time! 
|
|
|
|
|
Sorry for the advice man but i was really not aware of the fact that handles cant be shared across the processes.
Regards,
Sandip.
|
|
|
|
|
Hi Sandip. its ok. you helped me out not to do the clipboard solution anyway. Thank you. 
|
|
|
|
|
Hi Naveen,
Thanks for the information.
Regards,
Sandip.
|
|
|
|
|
|
|
Hamid. wrote: Why you dont use of WM_COPYDATA?Inter-Process Communication using WM_COPYDATA[^].
Thank you for the suggestion. I am looking into it right now but the size of the bitmap bits actually is not a constant value. So I'll be needing a pointer for that in which WM_COPYDATA can't be used. I'm still checking some other routes like named pipes, or shared memory. Any further suggestions? Thank you!
|
|
|
|
|
hi
i have aquestion i really need an answer for it because it frustrated me...
look at these two functions:
void CSecondDlg::OnButton1()
{
FILE *fp;
FILE *file1 = fopen("file1.txt","w");
int nFileLong;
char strFilter[] = { "CPP Files (*.cpp)|*.cpp|All Files (*.*)|*.*||" };
CFileDialog m_ldFile(TRUE, ".cpp", NULL, 0, strFilter);
if (m_ldFile.DoModal() == IDOK)
{
m_sFileName=m_ldFile.GetPathName();
fp=fopen(m_sFileName,"rb");
fseek(fp,0,SEEK_END);
nFileLong=ftell(fp);
char* sText = new char[nFileLong+1];
fseek(fp,0,SEEK_SET);
int i=fread(sText,1,nFileLong,fp);
sText[i]=0;
m_EDIT1=sText;
fprintf(file1,"%s\n",m_EDIT1);
fclose(file1);
fclose(fp);
UpdateData(FALSE);
}
}
AND
void CSecondDlg::OnButton2()
{
FILE *fp;
FILE *file2 = fopen("file2.txt","w");
int nFileLong;
char strFilter[] = { "CPP Files (*.cpp)|*.cpp|All Files (*.*)|*.*||" };
CFileDialog m_ldFile(TRUE, ".cpp", NULL, 0, strFilter);
if (m_ldFile.DoModal() == IDOK)
{
m_sFileName=m_ldFile.GetPathName();
fp=fopen(m_sFileName,"rb");
fseek(fp,0,SEEK_END);
nFileLong=ftell(fp);
char* sText = new char[nFileLong+1];
fseek(fp,0,SEEK_SET);
int i=fread(sText,1,nFileLong,fp);
sText[i]=0;
m_EDIT2=sText;
fprintf(file2,"%s\n",m_EDIT2);
fclose(fp);
fclose(file2);
UpdateData(FALSE);
}
}
as u can see the two functions do the same thing :
open afile into an edit box ....then save the content of the edit box in another file (.txt)
what is bizzare??
well if i open browse1 and browse2 button ...i would find that the first file is created and the second not...(because i hit the button browse1 first).
if i try another time but with hitting browse2 first the opposite thing happend (the second file is changed but not the first )
what is wrong ????
i reaaaly dont know what to do ??
please help me with this
my project stopes on this....
thank u all
|
|
|
|
|
I can't seem to find the difference between two functions. Can you step through your program and see what exactly is going on?
-Saurabh
modified on Monday, June 23, 2008 2:07 AM
|
|
|
|
|
thanks for ur reply
but my application is simple ...two edit controls each with its "browse" button.
first load afile to edit .....then store the content of the edit to ".txt" file...
its that simple....
if u try it for the first time ...it works for both ...
but in second and third and .....etc times....the odd problem occures
??????????
what is it that i did wrong
please would u try it urself and help me understand and solve the problem
my project stop on this
thank u
|
|
|
|
|
It doesn't matter that application is simple or complex. Point is you have a bug in your application that means there is a problem some where. So as I suggested why don't you try to step through your program and check whats going on. Another idea is just create a new application and copy this code over because the code you provided works fine for me.
-Saurabh
|
|
|
|
|
Well your code (though a bit weird: duplication) works on my system.
BTW why don't you delete the allocated memory?
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]
|
|
|
|
|
how????
did u tried it multiple times...
and in both way worked???
please i really need to know whats wrong...
|
|
|
|
|
Yes it actually works.
I've made three tests:
(1) Button1 followed by Button2 (loaded two different files)
(2) Button2 followed by Button1 (loaded two different files)
(3) Button1 followed by Button2 (loaded the same file)
All of them were OK.
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]
|
|
|
|