|
Thank you.
All I needed is working well.
|
|
|
|
|
zudroj wrote: 1) How should I start threads? (CreateThread(),AfxBeginThread(),...)
Maybe the big design decision is between creating a worker thread or a User-Interface one (see [^] and [^]).
zudroj wrote: 2) How should I end threads? (EndThread() - ???)
Gracefully. Ask the thread itself to terminate (setting a flag, using a use a Synchronization Object [^], for instance, an Event, ...).
zudroj wrote: 3) How should I handle the part of code that must be processed only by one thread at a time?
Again, use a Synchronization Object [^] (for instance a Critical Section).
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.
|
|
|
|
|
Hi guys,
I am trying to use the Win32 API to fill a bitmap, using the function GetDIBBits(). My source bitmap is a 32-bit image, but I am hoping to create a 4-bit destination bitmap. I am of the understanding that this requires me to create a color table, and keep it in a BITMAPINFO structure. Does anybody see a problem with this snippet of code?
<br />
pbmi = (PBITMAPINFO) LocalAlloc(LPTR,sizeof(BITMAPINFO));<br />
<br />
<br />
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + 16*sizeof(long);<br />
pbmi->bmiHeader.biWidth = bmp.bmWidth;<br />
pbmi->bmiHeader.biHeight = bmp.bmHeight;<br />
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;<br />
pbmi->bmiHeader.biBitCount = 4;<br />
<br />
pbmi->bmiHeader.biCompression = BI_RGB;<br />
<br />
if (pbmi->bmiHeader.biSizeImage == 0)<br />
pbmi->bmiHeader.biSizeImage = WIDTHBYTES((DWORD)pbmi->bmiHeader.biWidth * <br />
pbmi->bmiHeader.biBitCount) * pbmi->bmiHeader.biHeight;<br />
<br />
pbmi->bmiHeader.biClrImportant = 0;<br />
<br />
for(i = 0; i<16; i++)<br />
{<br />
pbmi->bmiColors[i].rgbRed = 0;<br />
pbmi->bmiColors[i].rgbBlue = 0;<br />
pbmi->bmiColors[i].rgbGreen = 0;<br />
pbmi->bmiColors[i].rgbReserved = 0;<br />
}<br />
<br />
pbmi->bmiColors[1].rgbRed = 255;<br />
<br />
pbmi->bmiColors[2].rgbRed = 128;<br />
<br />
pbmi->bmiColors[3].rgbGreen = 255;<br />
<br />
pbmi->bmiColors[4].rgbGreen = 128;<br />
<br />
pbmi->bmiColors[5].rgbBlue = 255;<br />
<br />
pbmi->bmiColors[6].rgbBlue = 128;<br />
<br />
pbmi->bmiColors[7].rgbRed = 255;<br />
pbmi->bmiColors[7].rgbGreen = 255;<br />
<br />
pbmi->bmiColors[8].rgbRed = 128;<br />
pbmi->bmiColors[8].rgbGreen = 128;<br />
<br />
pbmi->bmiColors[9].rgbRed = 255;<br />
pbmi->bmiColors[9].rgbBlue = 255;<br />
<br />
pbmi->bmiColors[10].rgbRed = 128;<br />
pbmi->bmiColors[10].rgbBlue = 128;<br />
<br />
pbmi->bmiColors[11].rgbGreen = 255;<br />
pbmi->bmiColors[11].rgbBlue = 255;<br />
<br />
pbmi->bmiColors[12].rgbGreen = 128;<br />
pbmi->bmiColors[12].rgbBlue = 128;<br />
<br />
pbmi->bmiColors[13].rgbRed = 0;<br />
pbmi->bmiColors[13].rgbGreen = 128;<br />
pbmi->bmiColors[13].rgbBlue = 0;<br />
<br />
pbmi->bmiColors[14].rgbRed = 192;<br />
pbmi->bmiColors[14].rgbGreen = 192;<br />
pbmi->bmiColors[14].rgbBlue = 192;<br />
<br />
pbmi->bmiColors[15].rgbRed = 255;<br />
pbmi->bmiColors[15].rgbGreen = 255;<br />
pbmi->bmiColors[15].rgbBlue = 255;<br />
Am I missing something here?
Thanks
|
|
|
|
|
TheDelChop wrote: Am I missing something here?
Yes, you didn't allocate memory for the colour entries (pbmi->bmiColors[] ).
You have to do:
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFO) + 15 * sizeof(RGBQUAD));
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.
|
|
|
|
|
I am currently a student and have wondered into the realm of c++. The problem is that I am creating a program that can edit NC code for multi-axial milling machines. The problem is as follows.
I have the line of text that I wish to edit, this has been stored as a CString. And would look something as follows: N650 G1 X152.5 S5200
The only part of this string that I want to change is the S5200, and would like to change it to say S8000.
It isn’t possible to read the different parts of the code into the CString as the whole line is read from an XML. And the number of characters before the S5200 is not always constant
Is there a way to read the CString until the S Character is found and then write over it?
Any help with this would be much appreciated and my apologies if this is a menial question, it is however hard to find such information on something so specific.
Regards
Jason Smith
|
|
|
|
|
CString::Find() and CString::Replace() can help you in achieving this.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
jasn Smith wrote: Is there a way to read the CString until the S Character is found and then write over it?
Yes, assuming no other "S" precede the one you want.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi All,
I was just understanding how does MS set the font sizes. In an MFC application if we use CreateFont() API to create a font and set it's size to 8 and style to FW_BOLD.Something like this: myFont->CreateFont (8,0,0,0,FW_BOLD,0,0,0,0,0,0,0,0,"Tahoma");
This creates a font on the screen that is hard to read due to it's small size. But when we open MS-WORD and set it's font size to 8 and FONT to Tahoma, the user is able to read the text properly.
So are the values displayed in list box in MS-WORD used to set the font size? or they are just to let the user see the values and don't have much meaning?
In my application I would like to Create a font that shows as what Tahoma (size 8) is seen in MS-WORD.I am able to do this but not without setting the value (in bold above) to 12,14 or 16
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
It is ten times smaller then the real font. So pass 10*N to have a font with size=N.
--
=====
Arman
|
|
|
|
|
I figured that out. but that is applicable in case of CreateFontIndirect(). I had tried it, but still the size differs from what is actually seen in WORD
-- modified at 9:31 Monday 4th June, 2007
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Font heights are in logical units. MS WORD is WYSIWYG so the logical units you enter in the
font dialog are converted to the correct size font based on the size of the displayed document.
If you aren't worried about exact font sizes, use an arbitrary negative height.
If you need your font size based on actual dimensions then you'll need to convert the logical
units to device units: Height = -MulDiv(PointSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
Here's the problem:
I have an ActiveX control and I want to change - more exactly cancel - the way it handles some basic input window events in a MFC application. (It doesn't export the events of course)
I've tried the "classic" SetWindowLong way for Win32 API subclassing but it doesn't seem to work and I didn't really expected (or maybe I'm not using it right.. I don't know..)
I have the ActiveX Control placed in a dialog. The class instance variable for the Control is a member variable of the dialog class.
In OnInitDialog I have the next lines of code:
CWnd * wnd_ctrlax = GetDlgItem(IDC_PLUGIN1);<br />
HWND handle_ctrlax = wnd_ctrlax->GetSafeHwnd();<br />
old_wnd_proc = (WNDPROC)SetWindowLong(handle_ctrlax, GWL_WNDPROC, (LONG)Subclassing);
old_wnd_proc and Subclassing are both declared global. (Maybe here I'm doing something wrong...)
The new WndProc looks something like this:
LRESULT APIENTRY Subclassing (HWND hWnd, <br />
WORD Message, <br />
WORD wParam, <br />
LONG lParam)<br />
{<br />
<br />
if (Message == WM_LBUTTONDBLCLK)<br />
{<br />
return 0;<br />
}<br />
<br />
if (Message == WM_LBUTTONDOWN)<br />
{<br />
return 0;<br />
}<br />
<br />
return CallWindowProc(old_wnd_proc, hWnd, Message, wParam, lParam);<br />
}
I've put breakpoints in the new WndProc handles for the mouse click messages. Of course they never get trigerred.. but the WndProc is entered = a breakpoint on the return CallWindowProc line is triggered continuously.
It just doesn't catch my mouse input in the control = the old functionality remains the same.
If somebody had the some problem or knows an answer for subclassing an ActiveX control and can give me a hint I'll really apreciate it.
-- modified at 8:37 Monday 4th June, 2007
|
|
|
|
|
dkmr wrote: CWnd * wnd_ctrlax = GetDlgItem(IDC_PLUGIN1);
When you insert an Activex to your dialog, two windows are created. In your case the first one is the IDC_PLUGIN1. The other window is created as the child of IDC_PLUGIN1. This widnow is the actaull activex you see. So get the child window of IDC_PLUGIN1 and try subclassing it.
|
|
|
|
|
my application runs in two modes.”online” mode and “offline” mode.by default,application will be in offline mode.when clicking online button in the tool bar,mode will change to offline.what i want is an indication system.when application is in online,an icon should come indicating "ONLINE" untill mode changes to OFFLINE.and vice vorsa.i 'm using MFC.using toolbar,or dialoge bar ,what s the code to create this?same button in the toolbar is using to swiching between two modes.for first click" online " button should come and on second click "offline".try it out.
|
|
|
|
|
You could either put the indicator in the toolbar, or at the bottom in the status line (i.e., similar to the CAPS and NUM indicators).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i think its better to use a dialog bar
Proud To Be an Indian
|
|
|
|
|
vivekphlp wrote: i think its better...
I was merely giving options, not opinions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ok sorry
Proud To Be an Indian
|
|
|
|
|
Hi everone,
I'm developing an Internet Explorer add-on,which will put an extra image on the document's specified location.Everything works fine,but Internet Explorer won't display the image if it is located in the local system (the user's computer,i mean).Since I'm sure the image url (formed as 'file://c:/folder/image.gif ') is correct and IE displays images on the internet,I think it's a kind of security feature of IE.
Does anyone have any idea on how I can put a local image on the document without asking the user to alter security settings?
|
|
|
|
|
I have created an SDI application. There i have created 3 dockable toolbars without using Rebars. The problem is that all toolbars appears in a separate line. I want them to be on after the another. How to do this.
Please help me.
Anurag Gandhi.
|
|
|
|
|
Hi,
Could you please specify the styles CBRS_* used while creating and docking it.
Best Regards
Raj
|
|
|
|
|
Following is the complete functiom:
Similar is the function for other two toolbars also.
bool CMainFrame::AddMarginToolbar()<br />
{<br />
if (!m_MarginToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP<br />
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||<br />
!m_MarginToolBar.LoadToolBar(IDR_MARGIN))<br />
{<br />
TRACE0("Failed to create Case toolbar\n");<br />
return false;
}<br />
m_MarginToolBar.SetWindowTextW(_T("Margin"));<br />
<br />
m_MarginToolBar.EnableDocking(CBRS_ALIGN_ANY);<br />
EnableDocking(CBRS_ALIGN_ANY);<br />
DockControlBar(&m_MarginToolBar);<br />
return true;<br />
}
I want that next toolbar should appear automatically previous first toolbar.
Thanks a lot in advance.
Anurag Gandhi.
|
|
|
|
|
Hi,
You need some thing more to get this, you need to use the full parameters of
DockControlBar();
for instance if you want to set the toolbar before the first tool bar aligned on top
you can do this,
DockControlBar(&m_MarginToolBar);
RecalcLayout();
CRect rect;<br />
m_MarginToolBar.GetWindowRect(&rect);<br />
rect.OffsetRect(1,0);
<br />
<br />
DockControlBar(&m_wndToolBarSecond, AFX_IDW_DOCKBAR_TOP, rect );
think and modify alignment according to your requirement.
Best Regards
Raj
-- modified at 9:54 Monday 4th June, 2007
|
|
|
|
|
Thanks a lot Raj.
I have implemented it and it is working fine.
Anurag Gandhi.
|
|
|
|
|
Hi. Ok slightly long explaination, I apologise!
I am currently developing a 3d drawing system and am having a few problems with storing the vertexes of each line.
Basically there are two objects that I am using to construct a drawing: points and lines. A point stores the x y z coordinate of a vertex. Each point that is drawn is stored in a global vector of points. A line consists of many points and consists of a vector that stores a reference to each pointer in the global vector.
The problem I am having is that the vector of pointers in the line object start off pointing to the vertex in the global array but when another point is added to the global array it can no longer find it instead it comes back with the vertex being at some strange position, the most common coordinate being -1.5883997e38. I can see it may be something to do with how the global vector stores the point objects.
Ive checked:
The actual values of the pointers in the line vector do not change value
The global vector containing the points stores the points ok
Is this explanation enough or do I need to post code?
Kevin
|
|
|
|