|
if i was creating a control in a form i might do this:
ctrl->Create(WS_CHILD, r, this, ID_EXTENDED_EDIT);
ctrl->ShowWindow(1);
Which works fine, however I want my control to be a child of the desktop ie free floating modeless dialog box, so I thought:
ctrl->Create(WS_CHILD, r, this->GetParent(), ID_EXTENDED_EDIT);
ctrl->ShowWindow(1);
would work, but it crashes and I cant see why... any help?
|
|
|
|
|
I'm willing to bet that Microsoft doesn't want you to be able to do that, maybe they feel it would affect there OS in some way but at any rate I doubt you can do it.
|
|
|
|
|
Hi all,
In my application, I develop a class CDIB for displaying the image. And now, I'd like to add some method such as: Brightness, Contrast, Colorize. But I don't know. Can you help me?
Thanks in advance for your reading.
Ngo Khai Hoa
|
|
|
|
|
To do this you need direct pixel access, which I assume your class has, i.e. I assume your DIB is a CDIBSection.
Brightness is easy, just add an amount to each of the RGB values for each pixel. Contrast involves trending high values up and low values down. What does colorise mean ?
The pointer to the pixel data is passed into the call that creates the DIBSection. If you want more info on different filters, I'd be happy to dig up something. If you're remotely serious you should buy Windows Graphics Programming by Feng Yuan, which contains heaps of info on filters ( it's where I initially learned about them ). There are also some newsgroups worth reading.
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.
|
|
|
|
|
Hi Christain,
First at all, thanks for your answer. Colorize means the image is drawed by one color. It is same as Colorize Function in ACDSee.
And my mind that I'd like do something same as image processing functions of WinWord.
Thanks in advance.
Ngo Khai Hoa
|
|
|
|
|
Oh, you mean make it all red, green OR blue ? That's easy. Step through the pixels and turn the two colours you don't want to 0. It's useful to actually have a filter that allows you to set a boost or cut to each colour channel.
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.
|
|
|
|
|
Hi Christian
Can you show me more detail for Brightness, Contrast.
Thank you very much.
Ngo Khai Hoa
|
|
|
|
|
If you're stepping through a 24 bit image, then it's like this
unsigned char * pPixel = pMyArray;
for (int y = 0; y < m_Height; y++)
for (int x = 0; x < m_Width; x++)
{
pPixel[0] += m_Brightness;
pPixel[1] += m_Brightness;
pPixel[2] += m_Brightness;
pPixel += 3;
}
Basically unsigned char runs from 0-255, so you don't need bounds checking. We step through all the bits and add the brightness value, which can be negative. The only thing that is worth mentioning, although it doesn't matter in this case, is that Windows bitmaps are stored as BGR, not RGB.
Here is a contrast filter:
register double red, green, blue;
register double csupp = contrast * (m_offset - 125.0) + 125.0;
for (int y = 0; y < pBmpDest->GetHeight(); ++y)
{ // For each line
register BYTE * pSrcPixel = pSrcLines[y];
register BYTE * pDstPixel = pDstLines[y];
for (register int x = 0; x < destWidth; ++x)
{
// Formel für Kontrastberechnung:
// v = (contrast * (v - 125.0 + m_offset) + 125.0);
red = contrast * ((double) (pSrcPixel[RGBA_RED])) + csupp;
green = contrast * ((double) (pSrcPixel[RGBA_GREEN])) + csupp;
blue = contrast * ((double) (pSrcPixel[RGBA_BLUE])) + csupp;
if(red >= 255.0)
pDstPixel[RGBA_RED] = (BYTE) 255;
else if (red < 0.0)
pDstPixel[RGBA_RED] = (BYTE) 0;
else
pDstPixel[RGBA_RED] = (BYTE) red;
if(green >= 255.0)
pDstPixel[RGBA_GREEN] = (BYTE) 255;
else if (green < 0.0)
pDstPixel[RGBA_GREEN] = (BYTE) 0;
else
pDstPixel[RGBA_GREEN] = (BYTE) green;
if(blue >= 255.0)
pDstPixel[RGBA_BLUE] = (BYTE) 255;
else if (blue < 0.0)
pDstPixel[RGBA_BLUE] = (BYTE) 0;
else
pDstPixel[RGBA_BLUE] = (BYTE) blue;
pSrcPixel += inc;
pDstPixel += inc;
}
}
All the bounds checking is superfluous as I mentioned before. I got this from paintlib, which is available from www.paintlib.de, and has a lot of filter code in it. I'd be happy to send you other filters I have written, including smooth, sharpen, emboss, etc.
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.
|
|
|
|
|
Thank you very much. But If I have some problems, I will ask you again (~_*)
Ngo Khai Hoa
|
|
|
|
|
By all means
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.
|
|
|
|
|
I have a simple dialog based application that employs a RichEditCtrl (Microsoft Rich Text box control 6.0 (SP4)).
I have included AfxInitRichEdit() when the application is initialised.
On the system that the program was developed it works fine in both debug and release version.
When it is installed on another PC the program fails to display.
Both systems are configured with the same operating system NT 4 (SP5).
Can any one help me.
Note:
1. I have verified that the files listed in the Depends tracker are the same on both systems. Ensuring that the files listed were the same on both machines did not resolve the problem.
2. If I install Visual C++ V6 along with SP5.0 and then uninstall Visual C++, the program works fine. This is the only difference between the development platform and the target platform.
3. The sample program WordPad works fine without needing to install visual C++ on the target pc. Does this infer that the CRichEditView class should be associated with the RichEdit control in some way if so how do I associate it with the instance of the Edit control on the dialog.
Thanks in Advance...
|
|
|
|
|
hi,,
I like to know how can i serialize bitmaps..
I'm using the following codes, but it doesn't work.
void CEdgeDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
m_bmpBitMap.Serialize(ar);
}
else
{
// TODO: add loaing code here
m_bmpBitMap.Serialize(ar);
}
}
I don;t have a bitmap class, m_bmpBitMap is a CBitmap object.
1-should I have a Bitmap class?
can someone giude me please.
Thanks
Ehsan Behboudi
|
|
|
|
|
How else to easily share code between projects? Right now I have MSVC create project subfolders of the c:\devel directory and I have a bunch of .cpp and .h files for common functions in a c:\classes directory. Whenever I need a frequently used class I just 'add files to project' from c:\classes and then #include "c:\classes\foo.h".
I've never worked on projects with other people before, but I can see that I should find another way to do it in case I have the opportunity to collaborate in the future.
|
|
|
|
|
Always use #include with relative path for example #include "..\classes\foo.h" , in this way you will be able to move the project with out any problems.
|
|
|
|
|
First, it's a good idea for everyone to have the same directory structure (if for no other reason that to serve as a common frame of reference). For instance, I have the following directory structure for ne of my projects:
\Johns Projects\ --- CommonFiles
--- DeMONS2\ --- D2CommonFiles
--- D2Config
--- D2Launcher
--- D2Scrub
With the directory structure described above, any project in the johns projects root can get to any header file in CommonFiles or D2CommonFiles, even if "Johns Projects" has another name or is copied (in its entirety) to another drive altogether
In your project settings dialog...
1) Click Project | Settings... in the Visual Studio menu.
2) On the left side of the dialog, you'll see a combo box labeled "Settings for:". Select "All Configurations".
3) On the right side of the dialog, select the "C++" tab, and in the combo box labeled "Category:", click the "Preprocessor" item (last one in the list).
4) In the edit field lebaleled "Additional Include Directories:", and your relative path. Using the directory structure example above, for all of the projects in the DeMONS2 folder (D2Launcher, D2Config, and D2Scrub), I used "..\..\CommonFiles,..\D2CommonFiles".
At this point, all you have to do is #include the filename itself without worrying about the path at all.
In order to share a project, everyone will find it much simpler to just have identical directory structures.
|
|
|
|
|
Hi,
I have a graphical MDI application, it displays Bitmaps, draws points, lines,...
All the data is in my CView class.
Can I use serialization from CView? if yes.. How??
thanks
Ehsan Behboudi
|
|
|
|
|
I've been trying to do this for longer than I care to admit and every implimentation I try reactivates the last window that was active, even if my mouse is a long way away from it, over another view entirely.
Please help, or alternatively please send me a nice long piece of rope, and instructions on how to tie a noose.
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.
|
|
|
|
|
Try this:
1) Create a base view class that all ytour other views derive from.
2) Create a member variable of type CRect (we'll call it m_windowRect)
2) Override OnSize()
3) In the OnSize() function, insert the following code:
GetWindowRect(&m_windowRect);
ClientToScreen(&m_windowRect);
4) Override the OnMouseMove() function
5) In the OnMouseMove() function, insert the following code:
if (GetFocus() != this)
{
ClientToScreen(&point);
if (m_windowRect.PtInRect(point)
{
SetFocus();
}
}
I havn't tried any of this myself, but it should work with minimal tweaking.
|
|
|
|
|
Thanks, but I've tried it and apart from keeping the rect as a member variable, it's pretty much where I started out, and the same problem is evident - the last view highlighted activates instead of the one the mouse is over. I've gone so far as to iterate through all my views and grab their positions, but no matter what I do, the last view highlighted gets activated...
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.
|
|
|
|
|
Have you tried using WindowFromPoint() ?
Neville Franks, Author of ED for Windows
http://www.getsoft.com
|
|
|
|
|
I love you, and I want to bear your children.....
I spent half a day searching the MSDN for this API function - thanks, I'll give it a try.
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.
|
|
|
|
|
OK.. I am drawing a graph in my view and then want to save the point array in my document. Problem arises when i serialise.. During run, when I try to save it, he save window comes up fine.. but the graph is erased when my view is redrawn after closing the save dialog box. I did put invalidateRect in my OnDraw function .. but didn't work!!
I also added a call to UpdateAllWindows in the overriden Serialize function for my CDocument.. but still does not work!!!
also, anyone knows how to obtain a pointer to the current view from CDocument??
It is what we choose to be that makes us what we are, far more than our abilities.
-J.K. Rowling
|
|
|
|
|
To get a pointer to the View from your document:
CFrameWnd *pFrameWnd = (CFrameWnd *)AfxGetMainWnd();
ASSERT (pFrameWnd != NULL && pFrameWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)));
pFrameWnd = ((CMDIFrameWnd *)pFrameWnd)->GetActiveFrame();
CMyView * pView = (CMyView*)pFrameWnd->GetActiveView();
This is a generic method - it works from anywhere, but only works if your document is attached to the active view.
Your other problem is a mystery to me. Could you post some code to show what you're doing ?
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.
|
|
|
|
|
How can I in get MX Records from DNS when I know only hostname or ip of main server?
Please Reply to my email:piopawlu@interia.pl
Piotr Pawluczuk
|
|
|
|
|
Does anyone know how to use DeviceIoControl()??? I read the document from microsoft and MSDN...but still don't know how to use it.....can anyone give me a small tutorial about this function?
Thanks
|
|
|
|