|
ok i have the pixals per inch, what do i do with them to convert the rect?
|
|
|
|
|
Hi :
I'm a VC++ beginner and i have a problem with stand alone (.EXE) MFC application!!
Whenever that i want to run a .EXE file written with mfc in other machine i recieve the
following error for example :
The MFC42D.DLL not found....and etc.
Now i want to know what files(.DLL or ...) are needed for running a MFC program.
Please Help Me.
My english isn't very well because it isn't my native language,excuse me for bad
comments.
|
|
|
|
|
You need to compile your app in Release mode, not debug. You can watch the file dependencies with "Dependency Walker"
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi guys
I've discovered that my problems about GDI resources are due to use a class designed for NT or w2000 working in w98.
How could I discover what calls are exclusive for w2000?
The class is a CStatic derived class that works like a 2 states button, changing the bitmap from one to another depending the state.
I don't know if this info is enough for you.
Best Regards
Dr. pi
|
|
|
|
|
doctorpi wrote:
How could I discover what calls are exclusive for w2000?
By reading the documentation?
|
|
|
|
|
I don't know how to progamme an application without tittle bar,menu bar, toolbar, status bar... such as many games we have been seen. Please help me.
(I'm sorry! My English is not good.)
|
|
|
|
|
What you want is a Dialog based application. The default is:
1) No menu bar
2) No toolbar
3) No status bar
To get rid if the title bar go to the dialog properties and and clear the title bar option.
Art
|
|
|
|
|
Hello,
I have a dialog window based on CPropertySheet and I've added 2 CPropertyPages.
I have 2 questions:
1) The constructor gives me also an apply button, but I can't find a way to get rid of it. I don't need it.
2) On my CPropertyPages I also have a default button. If I press <enter> the dialog closes instead of doing the functionality behind my page default button.
I tried to override the OnOk on my Page, this shows my test message, so it is executed, but still the dialog closes. Any ideas how to override the CPropertySheet dialog default button so my CPropertyPage default button is executed, and nothing else?
Thanks
Wim
|
|
|
|
|
1) here is some code that builds a property sheet and gets rid of apply
CPropertySheet CompSheet("Company Information");
CCompBasic page1(pComp, TRUE);
CCompAddr page2(pComp);
CCompBank page3(pComp);
CCompDiscountMaint page4(pComp);
CompSheet.AddPage(&page1);
CompSheet.AddPage(&page2);
CompSheet.AddPage(&page3);
CompSheet.AddPage(&page4);
CompSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
2)in your dialog's onok you are probably still calling onok which is passed to the sheet.. at least thats my initial guess..
CMyDialog::OnOK()
{
AfxMessageBox("woop!");
} i may be way off on the 2nd one.. but the 1st will work..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Hello,
Thanks.
The first part removed the apply button.
The default button behaviour is still there am afraid.
I dont't have any default calls in my overrided functions, stil he just act like if the OK button was pressed.
I will have to explore the caves of CPropertySheet I suppose.
|
|
|
|
|
Looks like I first had to dig in the codeproject articles :
This[^] article shows in detail how to do it...
|
|
|
|
|
Hi guys
I'm having a problem with my last app.
My GDI resources are going down just executing it and close it (I've detected in W98).
What tool do you suggest to me to use in order to find where is the problem?
Thanks in advance.
Dr. Pi
|
|
|
|
|
visit this link to the MSDN and download the accompanied program (you'll find its link at the top of the page).
http://msdn.microsoft.com/msdnmag/issues/01/03/leaks/default.aspx
The tool GDIUsage will help you to find what is leaking exactly. For example, if there is an increase in Pen objects then you have some calls to SelectObject() that selects pens and you do not return the old pen, if there is increase in DC objects, then you probably use GetDC() without calling ReleaseDC() , and so on. Note that this utility doesnt work under WinNT/2000/XP
|
|
|
|
|
how can i play an enhaced metafile (100*100 log. units) on a dibsection (100*100 pixels)?
the code below should do the following:
1. create a dc
2. create a dib section for that dc which has the same width/height in pixels as the
emf in logical units (0.01 mm)
3. play the emf on that dc in such a way that 1 logical unit is mapped to 1 pixel,
meaning: the entire emf is drawn on exactly the bitmap/dc
rest. give me pointers to header/bits, so i can store 'em into a file
: m_dc = device context for emf
: m_file = handle to emf
: m_bounds = bounding rectangle of emf
: Close performes closing of emf, sets m_file/m_dc to proper values
however, i get to see only a small part of the emf in my bitmap
so it would be nice if someone had an idea on how to fix it.
btw: if i use other values than BI_RGB and 32 to that method, my bitmap is black...
this question is somehow related to my previous question
http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20545052.html
c_boolean FC CImage::GetDIBBits (r_pointer abits, r_dword asize,
r_pointer aheader,
r_dword aheadersize,
c_dword compression,
c_word bitsperpixel)
{
boolean retval = false;
abits = 0;
asize = 0;
aheader = 0;
aheadersize = 0;
if(Close())
{
dword adc;
adc = CreateCompatibleDC(m_dc /* same result as with 0 */); //-------> point 1
if(adc)
{
dword bmp;
rect r;
zero(&r, sizeof(r));
r.right = m_bounds.right - m_bounds.left;
r.bottom = m_bounds.bottom - m_bounds.top;
bitmapinfo b;
dword bihsize = sizeof(bitmapinfoheader) -
(_STDPALLEN * sizeof(rgbquad));
zero(&b, sizeof(b));
b.header.size = sizeof(b.header);
b.header.width = r.right;
b.header.height = r.bottom;
b.header.planes = 1;
b.header.compression = BI_RGB;
b.header.cstype = LCS_sRGB;
b.header.bitcount = 32;
pointer p;
bmp = CreateDIBSection(adc, &b, DIB_RGB_COLORS, p, 0, 0); //-------> point 2
if(bmp)
{
SelectObject(adc, bmp);
if(SetMapMode(adc, MM_TEXT)) //-------> beginning of point 3
{
PlayEnhMetaFile(adc, m_file, &r);
if(GdiFlush()) //-------> the rest
{
bitmapinfo* p;
if(bitsperpixel>16) bihsize += (1 << bitsperpixel) * sizeof(rgbquad);
p = (bitmapinfo*)allocate(bihsize);
if(p)
{
p->header.size = sizeof(p->header);
p->header.width = r.right;
p->header.height = r.bottom;
p->header.planes = 1;
p->header.compression = compression;
p->header.cstype = LCS_sRGB;
p->header.bitcount = bitsperpixel;
if(GetDIBits(adc, bmp, 0, r.bottom+1, 0, &b, DIB_RGB_COLORS))
{
if(p->header.sizeimage <= 0)
{
p->header.sizeimage = (((p->header.width * p->header.bitcount + 31) & ~31) * p->header.height) / 8;
}
pointer bits = allocate(p->header.sizeimage);
if(bits)
{
if(GetDIBits(adc, bmp, 0, r.bottom+1, bits, p, DIB_RGB_COLORS))
{
abits = bits;;
asize = p->header.sizeimage;
aheader = p;
aheadersize = bihsize;
retval = true;
}
else IMAGE_ERROR;
}
if(!(retval)) free(bits);
}
else IMAGE_ERROR;
if(!(retval)) free((r_pointer)p);
}
else IMAGE_MEMORY;
}
else IMAGE_ERROR;
}
else IMAGE_ERROR;
DeleteObject(bmp);
}
else IMAGE_ERROR;
DeleteDC(adc);
}
else IMAGE_ERROR;
}
else IMAGE_EMPTY;
return retval;
}
thanks in advance,
Thomas
|
|
|
|
|
hi fellows,
i encountered a strange problem i cannot solve that easy:
i want to do the following:
- read an enhanced metafile from disk
- create an new enhanced metafile device context in memory
- play the loaded emf on this context
(therefore the bounding rectangles should match i think)
- now i can draw on the dc over the loaded emf
- store the new emf on disk
(the old one is in the background, maybe some text/line is drawn above)
up to now i did in my member function of a class:
dword z = GetEnhMetaFileA(afilename);
if(z)
{enhmetaheader h;
if(GetEnhMetaFileHeader(z, sizeof(h), h))
{
m_bounds = h.frame;
m_dc = CreateEnhMetaFileA(m_dc, 0, &m_bounds, IMAGE_NAME);
if(m_dc)
{
if(PlayEnhMetaFile(m_dc, z, &m_bounds))
{
m_clip = CreateRectRgnIndirect(&m_bounds);
if(m_clip) SelectClipRgn(m_dc, m_clip);
}
else IMAGE_ERROR;
}
else IMAGE_ERROR;
if(!(retval)) Clear();
}
else IMAGE_ERROR;
DeleteEnhMetaFile(z);
}
else IMAGE_ERROR;
the datatypes, functionprototypes and the macro IMAGE_ERROR look maybe odd
but work definitely
m_bounds is of type rect, a member variable
m_dc and m_clip are also member variables
i had two cases of error:
in the first, a self drawn and stored emf was loaded
(which can be loaded correctly with any graphics software),
the PlayEnhMetaFile fails but GetLastError returnes NO_ERROR.
if i store the result again with CloseEnhMetaFile and CopyEnhMetaFile,
the picture is shrinked to a very small rectangle in a huge white area.
in the second i try to load an emf generated by a graphics suite,
here it works all fine (at the first glance),
but if i try to store the result again, it gives me an empty
picture.
the storing routine works all fine (since i can watch
self-generated and stored emfs)
so what's wrong?
can somebody help me?
|
|
|
|
|
First:
How can I get the number of lines in a string (basic_string ) object?
After I know the number of lines I will create an array like this:
string lines[number_of_lines];
Then, I want to put each line from a string into this array, but how?
Is the only way to find each \n and then make a substring from the beginning to the position of \n?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
You could use CString::Replace(..) fn replacing the \n with the same thing \n. This will leave the string unchanged and return the total number of occurances ie. your line count. After you use it to create your new array you can then tokenize you string into substrings.
Art
|
|
|
|
|
Art Friesz wrote:
You could use CString::Replace(..) fn
No, I could not... I'm not using MFC at all in this project!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
Is the only way to find each \n and then make a substring from the beginning to the position of \n?
Yes.
Also, string lines[number_of_lines] is not going to work since number_of_lines won't be constant. You can allocate the array dynamically, or better yet use a vector.
Regards,
Alvaro
Quitters never win. Winners never quit. But those who never win and never quit are idiots. -- despair.com
|
|
|
|
|
One solution is to loop through the source string and assign new lines accordlying.
Kuphryn
|
|
|
|
|
i have a function which vb is calling from my c++ dll.. the function takes a little while so i wanted to popup a dialog telling them to wait a bit.. im assuming that i cant popup a dialog from a dll as i am crashing when i tell the dialog to go modal:
INT_PTR CDialog::DoModal()
{
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle(); <--- crashing here is there a built in messagebox that doesnt have an ok or cancel that i can show and hide without needing a resource? i have a progresswnd that i got here from CP, but it crashes because i pass NULL for the parent.. is there a way to tell the parent that is calling the dll's function? or a way to pass a CWND pointer from VB into my function?
thanks for ne tips!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
woops looks like i was crashin with the progress window because i left out the following in the begining of my dll's function:
AFX_MANAGE_STATE(AfxGetStaticModuleState()); woops! but for reference, is there a window built into mfc i can show and hide with no ok or cancel on it?
thanks!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
dazinith wrote:
is there a window built into mfc i can show and hide with no ok or cancel on it?
Nope. That would have made MFC more than just a wrapper class library, and (apparently) the MFC developers didn't want to work too hard.
Regards,
Alvaro
Quitters never win. Winners never quit. But those who never win and never quit are idiots. -- despair.com
|
|
|
|
|
// All records in CObArray Pids have same data
// after for loop.
CObArray Pids;
CAPidT* T=new CAPidT; // CAPidT is public of CAPid;
CAPid* Q=new CAPid;
CString s;
int n=pDoc->m_iSelectedPids;
Pids.SetSize(n);
for(int i=0;i<n;++i)
{
="" q="(CAPid*)pDoc-">m_obaSelectedPids[i];
T->SetPid(Q);
Pids[i]=T;
}
Thanks.
|
|
|
|
|
please reformat the code. Use the < > buttons below for the <> signs because they get eaten by the codeproject beast.
After it's reformated, can you tell us what is the problem ? does it crash, does it give bad results ?
Are you sure you don't go over the array bounds in the loop ?
Thanks.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|