|
Hi,
I have a bitmap file with image size 720*480. Now i want to draw a part of this image, such as draw the image within a rectangle
rect(360, 420, 240, 280). Is there a simple method to do this?
Best Regards,
chen
|
|
|
|
|
BitBlt and StretchBlt both allow you to specify the part of the image to draw.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
it depands speed u need for drawing.
1. if need high speed, u have to draw it from file buffer, in the case, u need to know bitmap format, it is not too hard, but hard to draw because all DC functions are nor available.
2. create a memory DC, display bmp file on it, then draw it with DC functions. if u want to change ur file, save it according to ur memory DC.
includeh10
|
|
|
|
|
Thanks for the reply. It worked!
Best Regards,
chen
|
|
|
|
|
Hi, can someone show me a code or webpage to get size and position of a CDialog? how do I set position and size again? Thanks for help.
|
|
|
|
|
GetWindowRect & SetWindowPos
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hi,
I'm using the function WNetAddConnection2( ) in my application.But on compiling my project it gives the following Linker error.
Generating Code...
Linking...
BackupDlg.obj : error LNK2001: unresolved external symbol _WNetAddConnection2A@16
Debug/Backup.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
can anyone help me?
With regards
Shibu K.V.
Senior Research Associate.
VLSI ASIC Hardware Design Group
Electronics R&D Centre,Trivandrum
India
|
|
|
|
|
I assume your linking in Mpr.lib?
Normski. - Professional Windows Programmer
|
|
|
|
|
Are there any articles on the help features like the "?" box in the right hand corner and things associated with that on this site? I can't seem to find any.
-Raffi
|
|
|
|
|
I have a class which can calculate a mathematics expression,such as "sin(x)+cos(x)",when given a number to x, it could return the value of the expression.It works in two steps:At first,it parses the expression,and then,it calculates.I have a list of x's values,all of them are used in the expression "sin(x)+cos(x)",so they are calculated in the same way,but the class parses the expression for each x value,you see, it does the same work many many times.What can I do if I want the class to parse once but calculate all?
|
|
|
|
|
Make a static array, which is a lookup table. Then each sin or cos is calculated exactly once.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hi All,
I need a Lint checker or something simular for my large C++ program in order to find a bug that is crashing it.
Can anyone suggest a good Lint Checker? Really, I would love a free one??
Thanks !
Philip
|
|
|
|
|
Lint may be of some use, but I'd surprised if it would pinpoint your crash.
Have you tried running a Debug Build under the VC Debugger and inspecting where the crash occures when it happens?
Also have a look at the various BugSlayer articles by John Robbins on the MS MSDN Web site http://msdn.microsoft.com/default.asp and "Improved Error Reporting with DBGHELP 5.1 APIs" http://msdn.microsoft.com/msdnmag/issues/02/03/Hood/Hood0203.asp
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
This is a new one for me.
I have a buffer, i.e., char buffer[100]. I need to copy the contents of the buffer into a BSTR that is already allocated and already has a value. Basically, I need to change the value of the BSTR before I send it to another method that requires a BSTR. I cannot figure out how to do this? Any advice?
Thanks for any help,
Shanti
|
|
|
|
|
comutils.h includes a wrapper class called _bstr_t. You can do this:
HRESULT MyFunc(/*[in, out]*/BSTR * bstr)
{
_bstr_t b_tWrap(*bstr, false); // FALSE means the _bstr_t takes ownership
b_tWrap = mycharbuffer;
*bstr = b_tWrap.Release();
}
Something like that.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
I was interested in this answer too. But, how do you do it in C? Also, how would you convert a BSTR or Variant to a char buffer?. Kind of hard to find examples on how to do these things in C cuz all examples in MSDN etc. only use C++. I'm modifying an existing C program to use COM/OCX and keep running into these kinds of problems.
|
|
|
|
|
JohnnyG wrote:
Also, how would you convert a BSTR or Variant to a char buffer?.
I don't know. There are a range on conversion functions, but I do not know if they are C or C++.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hey, I tried looking up your signature....in regards to a quote from Chris Losinger thinking that must have been an interesting thread but on Nov 7th, 2002, huh???? 11/7/2002 hasn't occurred yet. Typo or deliberate? Hee, hee.
|
|
|
|
|
I don't know the country breakdown for different date formats, but in Australia it's dd/mm/yyyy.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
This will work in a *.c file
#include <windows.h>
int foo(BSTR string)
{
char buf[255];
int len = *(long *)(string-2);
memset(buf,0,sizeof(buf));
strcpy(buf,"Hello World");
mbstowcs(string, buf, len);
return 0;
}
|
|
|
|
|
Thanks, Mel. I'll give that a try.
|
|
|
|
|
Hi I'm trying to reposition like so:
void CForm2View::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
m_editbox1.MoveWindow(0,0,cx,cy,TRUE );
}
except that I modified the code at
http://www.codetools.com/docview/centermdiwnd.asp
to make the CFormView fit exactly and immovably in my MDI frame (took away draggability of the view as well).
The above is causing a debug assertion.
The foll shows the messagebox but doesnt like setwindowtext either:
void CForm2View::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
//MessageBox("aaaa");
// m_editbox1.MoveWindow(0,0,cx,cy,TRUE );
m_editbox1.SetWindowText ("moving!!");
MSDN says:
Example
// Resize the list control contained in the view to
// fill the entire view when the view's window is
// resized. CMyView is a CView derived class.
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// Resize list to fill the whole view.
m_List.MoveWindow (0, 0, cx, cy);
}
So I am confused. Please respond!
|
|
|
|
|
I see...
The problem is that OnSize() is call a first time when the view is created.
I tested that with a simple dialog based containing a button...
And it's OK...
bool m_bWait => a member of CMyDialog (which is a CDialog derived class)
CButton m_ctrlButton => a member of CMyDialog
class CMyDialog : public CDialog
{
public:
CMyDialog(CWnd* pParent = NULL) {
...
m_bWait = false; // initialize in the construtor
}
...
}
void CMyDialog::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if(m_bWait)
m_ctrlButton.MoveWindow(0, 0, cx, cy, TRUE);
m_bWait = true;
}
I hope that can help you
Hello World!!!
from Raphaël
|
|
|
|
|
Yuck. Much better to do this:
void CMyDialog::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (::IsWindowVisible(*this))
m_ctrlButton.MoveWindow(0, 0, cx, cy, TRUE);
}
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Of course... It's really better...
Hello World!!!
from Raphaël
|
|
|
|
|