|
Hello,
Here's my problem. I have a CListCtrl that supports in-place editing. I need to capture the Return key and notify the parent dialog that Enter has been pressed. I've tried the following:
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// If Enter has been pressed, we need to post a WM_KEYUP message to our parent dialog.
if(nChar == 13)
{
// Get a handle to our dialog window
CWnd* pDialogWnd = NULL;
pDialogWnd = GetParent();
// Post the message to our dialog window
pDialogWnd->SendMessage(WM_KEYUP, VK_RETURN, 0);
}
...
I think I'm going about this the wrong way but I'm not sure of the right way to do it. Any help would be greatly appreciated! I'm Stuck!
Thanks!
-Ian
|
|
|
|
|
You need to either create a custom message ( why does the keyup HAVE to mean something happened in a child dialog ? ), or pass an instance of the parent through to the child, and call a method on it directly. I'd define the method in an abstract class and derive from it, so that it's easy to change the parent dialog.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was using the keyup message because the code used to be in a CEdit-derived class in the WM_KEYUP handler.
A custom message would work, but I'm having trouble getting a handle to the dialog...
-Ian
|
|
|
|
|
I need some help for my project. i'm using MFC C++.
Actually i need to write a program tat can select the wanted region on an given image(256 by 256) to compute some calculation.... but before i can compute the calculation i need to differentiate the selected region i wan and the region tat is unwanted... so the wanted region i need is the thickness of hollow cylinder.... i need to draw a bigger circle first capture the pixel selected and store in a array call (Index [r][c]) and follow by drawing a smaller circle in the bigger circle capture the pixel in a array call (index_inner[r][c])...the wanted region is between the bigger and the smaller circle...
can u give me some tip for how to wirte the program
|
|
|
|
|
This sounds to me like a problem you should be able to solve without any interaction with a bitmap at all. You should be able to mathematically work out which pixels will be inside the first circle, then knock out any pixels that occur in the second.
But if you want to store the pixel values also, then you need to create a DIBSection, so you have a pointer to the pixel values. Then use a 24 or 32 bit bitmap so that the pixel values are stored there in an easy to read format. Or you can use GDI+, then the code looks the same as the pixel access code in my image processing articles ( which are in C# ).
Don't use get/setpixel unless speed is not an issue.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
My image used actually is black and white, it not colour..
sorry i didn't mention to u...
|
|
|
|
|
It's a 2 bit image ? OK - well you can either work out how to iterate through it by bitmashing, or you can convert it to 8 bit using GDI+ ( because they each byte will contain one pixel, and you'll just need to work out which palette value is black and which is white ).
So you have a 2 bit image, and you want to work out the pixel values within a donut, is that right ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Dear all:
I am now conducting a project that supports recording videos from TV card. I am wondering if some has similar experience such as capturing videos(using DirectShow) from analog TV card or USB webcam.
Please let me share your experience if possible.
Thank you very much.
Jeffrey
|
|
|
|
|
Is DirectShow on WinCE signifiacantly different from
DirectShow on Windows XP, etc? If not, and if it would
be any use I could "share my experince", which started
with my stumbling through the Amcap sample source code
and finished with my writing a full featured, skinable
video capture application and understanding a heck of a
lot more about DirectShow Filtergraphs than I did before.
Steve T
|
|
|
|
|
Steve:
Thanks a lot for your information.
Yes, there are a lot of differences between WinCE and XP as far as Directshow is concerned. For example, most filters are not supported in WinCE.
Actually, my previous project on XP started from amcap, too. However, when I migrated it from XP to CE, I found a lot of things needed to be done...
Jeffrey
|
|
|
|
|
This morning, I tried to create an instance for a Capture Graph Builder using the following code:
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild);
Unfortunately, it returns REGDB_E_CLASSNOTREG, which indicates "A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt."
I check the corresponding registrey in WinXP, the CLSID_CaptureGraphBuilder2 is associated with the qcap.dll, which does not exist in WinCE.
Does anybody has the solution? Thanks a lot.
Jeffrey
|
|
|
|
|
Can anybody answer my question?
Thanks a lot.
Jeffrey
|
|
|
|
|
Hi, can anyone explain what does the program below do in MFC C++.
void CMediVisionView::OnFileSaveasraw()
{
// TODO: Add your command handler code here//
FILE *raw;
int n;
unsigned short sdata;
static char BASED_CODE szFilter[] = "DICOM Files (*.txt)|*.txt|All Files(*.*)|*.*||";
CFileDialog dlg_save_as(FALSE, "dcm", NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter);
if(dlg_save_as.DoModal() == IDOK) {
raw = fopen("test.raw","a+b");
for (n=0; n
|
|
|
|
|
It shows that the person who wrote it doesn't know C++, but knows C.
It's very poorly written code to open a file dialog, and open a DICOM file which has been saved as a .txt file ( this is ridiculous ), and then it opens the file, and it scales every value by taking a new theoretical maximum value, and it assumes the old maximum was 256.
According to this, a RAW file is not 10 bit at all, it's just 8 bit, one byte per pixel.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can you advice on a better way to write this program?thks.
|
|
|
|
|
1. Don't put all variable declarations at the top of the function. C requires it, C++ does not, and it's ugly
2. ALWAYS give any variable you create a default value, when you create it.
3. Don't use crappy C FILE handles, use iostreams
4. Don't use a file extension with a known value and use it to store something totally different.
5. Don't integrate code into your code base if you have no idea what it does.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm trying to upload a file to its designated location. If the file already exists and is read-only it doesn't allow me to overwrite it. Before overwriting the file, I first check to see if it's READ-ONLY by calling GetFileAttributes(). Then I reset the attribute from read-only to normal. Somehow it doesn't return FILE_ATTRIBUTE_READONLY even when it's a read-only file. Instead it returns a value of 33. What does that value correspond to? And why is it that I can't remove the READ-ONLY attribute so that I can overwrite the file?
DWORD dwAttr = GetFileAttributes(filename);
if(dwAttr == FILE_ATTRIBUTE_NORMAL)
SetFileAttributes(filename, FILE_ATTRIBUTE_NORMAL);
CopyFile(source, dest, FALSE);
Thanks!
|
|
|
|
|
try :
if ((dwAttr & (FILE_ATTRIBUTE_READONLY)) != 0)
{
...
}
the return value from GetFileAttributes can contain multiple values (it's a bit mask).
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
So that worked but how can I remove the read-only attribute? I called SetFileAttributes(filename, FILE_ATTRIBUTE_NORMAL) but that didn't do the trick.
|
|
|
|
|
Could be that you don't have the necessary permissions / authority to change the attribute.
Look at the value returned by SetFileAttributes - that may give you an idea why the call did not do what you expected.
|
|
|
|
|
I am the administrator of my machine so permissions shouldn't be a problem. The SetFileAttributes(filename, FILE_ATTRIBUTE_NORMAL) returns 0. Am I missing something?
|
|
|
|
|
Nevermind. It works. Thanks for all your help.
|
|
|
|
|
So, don't keep us all in suspense.
What was the problem, and what was the solution?
|
|
|
|
|
Sorry...it was just my stupidity in changing the wrong file. Instead of changing the destination file's attributes, I changed the source file's.
|
|
|
|
|
Ah, I guess we will have to watch out for the same problem!
Thanks.
|
|
|
|