|
hi all there, i want a code that help me to insert any file type in a rtf file, i need to insert by code not drag drop by mouse so plzzzzzzzzzzzzz help me .......
Thanks alot
Metal Man
|
|
|
|
|
Hi. Can anyone help me on this: I need to read data from sound card on line in. All I want is to get the digitized data that represents the signal I apply to line in. If anyone could suggest me some docs, or anything related to this I would be thankful.
PLEASE HELP !!! Thank you.;)
|
|
|
|
|
|
hello,
I have a problem. the call SETWINDOWTEXT truncates the length of the displayed text to 259 characters (dialog based, ansi mode) (somebody else reported 159), i don't see any dots, also a lot of space is left on the bar. A getwindowtext will return the full original string.
I try to set a titlebar of my dialog with 3 strings which are left, center and right justified. I do this by inserting a lot of spaces between the strings
Things i can do, but don't wan't to:
- Change the active title bar font.
- Draw my own titlebar.
The following code will work on a 800x600 mode maximized dialog, but not on a 1600x1200.
<code>
void SetWindowText3(CWnd* TargetWnd, CString LeftText, CString MidText, CString RightText)
{
CRect Rect;
int CaptionWidth;
CFont font;
CDC dc;
NONCLIENTMETRICS ncm;
int LeftWidth;
int MidWidth;
int RightWidth;
int SpaceWidth;
int FillWidth;
int FillLeftWidth;
int FillRightWidth;
int PosCenter;
CString CaptionText;
/****************************************************************************
Figure out the maximum width of the caption text
****************************************************************************/
TargetWnd->GetWindowRect(Rect);
CaptionWidth = Rect.Width(); // get width of whole window
CaptionWidth -= 2*GetSystemMetrics(SM_CXBORDER); // Remove left and right the border width
CaptionWidth -= 2*GetSystemMetrics(SM_CXFRAME); // Remove left and right the frame width
if (TargetWnd->GetStyle() & WS_SYSMENU)
CaptionWidth -= 2*GetSystemMetrics(SM_CXSIZE); // Remove the icon and close button
else
CaptionWidth -= 5; // Remove extra edge if no close button
PosCenter = CaptionWidth/2;
if ( (TargetWnd->GetStyle() & WS_MAXIMIZEBOX)
|| (TargetWnd->GetStyle() & WS_MINIMIZEBOX) )
CaptionWidth -= (2*GetSystemMetrics(SM_CXSIZE)) - 1; // Remove the width of the minimizebutton
/****************************************************************************
Prepare the GetTextExtent function.
****************************************************************************/
ncm.cbSize = sizeof(NONCLIENTMETRICS); // i don't why this is used.
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS), &ncm, 0); // get the pointer to the nonclientmetrics struct
font.CreateFontIndirect(&ncm.lfCaptionFont); // Create a copy of the font used title bar
dc.CreateCompatibleDC(NULL); // Create an DC
CFont* pOldFont = (CFont*)dc.SelectObject(&font); // Make sure that gettextextent uses the correct font.
dc.SetMapMode(MM_TEXT); // Make sure that gettextextent returns PIXELS.
/****************************************************************************
Get various width in pixels of the thext
****************************************************************************/
LeftWidth = dc.GetTextExtent(LeftText).cx; // Get the text width of the left text.
MidWidth = dc.GetTextExtent(MidText).cx; // Get the text width of the mid text.
RightWidth = dc.GetTextExtent(RightText).cx; // Get the text width of the right text.
SpaceWidth = dc.GetTextExtent(_T(" ")).cx; // How many pixels does a space take
FillWidth = (CaptionWidth - LeftWidth -
MidWidth - RightWidth)/SpaceWidth; // How much space is left on the title bar?
/****************************************************************************
Bug Work around. Make sure text is never longer as 259 characters
****************************************************************************/
// if ((LeftText.GetLength()+MidText.GetLength()+RightText.GetLength()+FillWidth)>259)
// FillWidth = 259 - (LeftText.GetLength()+MidText.GetLength()+RightText.GetLength());
/****************************************************************************
Fill in the spaces between the text and write the text to the title bar
****************************************************************************/
FillLeftWidth = (PosCenter-LeftWidth-(MidWidth/2))/SpaceWidth; // Space (in characters) between left and middle
//FillLeftWidth = FillWidth/2; // Same as above, but midtext in middle of empty area
FillRightWidth = FillWidth - FillLeftWidth; // space (in characters) between middle and right
CaptionText = LeftText;
for (int loopy=0;loopy<FillLeftWidth;loopy++) // How many space are needed between left and middle?
CaptionText += _T(" "); // Add a space to the caption text
CaptionText += MidText; // Add the middle text to the caption text
for (int loopy=0;loopy<FillRightWidth;loopy++) // How many space are needed between middle and right?
CaptionText += _T(" "); // Add a space to the caption text
CaptionText += RightText; // Add the right text tot the caption text
TargetWnd->SetWindowText(CaptionText); // now actually set the windows text
/****************************************************************************
Delete temperary objects
****************************************************************************/
dc.SelectObject(pOldFont);
font.DeleteObject(); // Delete the font.
dc.DeleteDC(); // Delete the DC
}
</code>
|
|
|
|
|
|
Hello! I've seen some sample programs on how to use CRectTracker properly, but i only have seen it on ordinary CViews...
I noticed the problem when i used CScrollViews and when I'm scrolling..
When I scroll the view, the CRectTracker also scrolls, thats fine.. But when I scroll all the way to the right, the CRectTracker is supposed to disappear, since its coordinates is out of the view already, and thats fine... But When I scroll back to its position, i expected to see it back, but i didn't.... I want the CRectTracker to be appearing again..
How do i solve this?
|
|
|
|
|
Hello,
i'm programming a multithreaded communication application. Some of the communication operations are being hold in a a shared (for all threads) synchronized queue. the synchronized queue is using c++ 'CRITICAL_SECTION' handle (using the 'EnterCriticalSection' and 'LeaveCriticalSection' functions).
have three questions (actually it's two):
1) Is 'CRITICAL_SECTION' ensure FIFO threads access into the critial sections of code?
2) If not, what can i use to ensure FIFO access?
3) If yes, is there a better (less CPU time, less resources) way to ensure FIFO access to critical sections of code?
thanks
|
|
|
|
|
1. Yes. This first thread to request critical section using EnterCriticalSection acquires it. The others must wait until the critical section is released with LeaveCriticalSection. I have seen some articles, posts, and other submissions here at the CodeProject site arguing that a class wrapper is a good idea in case you experience an exception - the critical section will not remain locked by a thread experiencing the exception. You can also look into TryEnterCriticalSection if you do not want your threads to block for some reason.
2. You can also use Mutex if your data is accessed by multiple threads from multiple processes. IF the data is only acessed by a single process, the critical section is generally the easiest and the quickest, without getting into interlocked element usage.
3. Not really. The critical section has been the recommended element for single-process multiple-thread protection of sections of code.
|
|
|
|
|
Hello,
Are you sure that CRITICAL_SECTION handles the threads waiting in FIFO order?
MSDN does not reffer to it any where
could you point me to an article or something that talks about it?
thanks
|
|
|
|
|
I misunderstood your initial question, and thought you were trying to implement a FIFO stack or similar queue.
This is what MSDN had to say about the critical section:
Platform SDK : DLLs, Processes, and Threads : Critical Section Objects ; Last updated: April 2004
"A critical section object provides synchronization similar to that provided by a mutex object, except that a critical section can be used only by the threads of a single process. Event, mutex, and semaphore objects can also be used in a single-process application, but critical section objects provide a slightly faster, more efficient mechanism for mutual-exclusion synchronization (a processor-specific test and set instruction). Like a mutex object, a critical section object can be owned by only one thread at a time, which makes it useful for protecting a shared resource from simultaneous access. There is no guarantee about the order in which threads will obtain ownership of the critical section, however, the system will be fair to all threads. Unlike a mutex object, there is no way to tell whether a critical section has been abandoned."
|
|
|
|
|
Notice,
MS does not guarantee FIFO order when using CRITICAL_SECTION:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/initializecriticalsection.asp
I've tried to implement a FIFO critical section. But i think it consumes alot of CPU time. If anyone can look into it, it would be helpfull
thanks
H FILE:
****************************
#include <windows.h>
#include <stdlib.h>
#include <list>class uFIFOCriticalSection
{
protected:
CRITICAL_SECTION _EntryCritSection;
std::list<handle> mLst_events;
public:
uFIFOCriticalSection();
void Enter();
void Leave();
virtual ~uFIFOCriticalSection();
private:
// No copies do not implement
uFIFOCriticalSection(const uFIFOCriticalSection &rhs);
uFIFOCriticalSection &operator=(const uFIFOCriticalSection &rhs);
};
****************************
CPP FILE:
**********************
#include "uFIFOCriticalSection.h"
uFIFOCriticalSection::uFIFOCriticalSection()
{
InitializeCriticalSection (&_EntryCritSection);
}
void uFIFOCriticalSection::Enter() {
EnterCriticalSection(&_EntryCritSection);
//creating an event handle for this thread (when it goes out of the critical section
HANDLE my_event = CreateEvent(NULL, false, false, NULL);
HANDLE last_event = NULL;
//checking if there is a thread inside the critical section
if (!mLst_events.empty()) last_event = mLst_events.back();
//pushing this thread's event handle into the queue
mLst_events.push_back(my_event);
LeaveCriticalSection(&_EntryCritSection);
//if there is a thread inside the, (last_event != NULL -> 'mLst_events' IS empty)
//we'll wait for the single event to be signalled.
//NOTE: if the 'last_event' is already signalled, the function will not wait
//and if the last_event is closed (by CloseHandle) the handle is invalid
//and the function will return with 'WAIT_FAILED'. Both cases are good for us.
if (last_event != NULL) WaitForSingleObject(last_event, INFINITE);
}
void uFIFOCriticalSection::Leave() {
EnterCriticalSection(&_EntryCritSection);
//the thread had left the critical section.
//getting the related event handle
HANDLE my_event = mLst_events.front();
mLst_events.pop_front();//removing myself
LeaveCriticalSection(&_EntryCritSection);
//signalling this thread's event.
//if there is a thread wait on this event,
//it's will automatically started
SetEvent(my_event);
//no need for it anymore, we can close the handle to retain resources
CloseHandle(my_event);
}
uFIFOCriticalSection::~uFIFOCriticalSection()
{
//we must release all the threads
//DO WE? let's try not...
/* std::list<handle>::iterator itr = mLst_events.begin();
while(itr != mLst_events.end()) {
SetEvent((*itr));
itr++;
}*/
DeleteCriticalSection (&_EntryCritSection);
}
*****************
|
|
|
|
|
Hi all:
Can anybody gives me a fully explanations or references of FDT(File Directory Table).
Does it has something to do with the order appearing after the DOS command "dir"?
Thanks!
|
|
|
|
|
With FAT16, and possibly FAT32, the order in which files/folders are enumerated is governed by how they were added to the FAT initially. IIRC, files/folders on NTFS are enumerated alphabetically.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks! Then how can I retrieve the FTD for specific folder?
|
|
|
|
|
I'm not familar with FTD in the context of folders. Could you be more specific?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I have to create two propertysheets at runtime in dialog box.
when i run the project i get the last property sheet with dialog box and other controls
hidden.
if i run the project commenting one propertypage and viceversa i am getting the property
page and all the controls.
after creating each property sheet i used to call the modify style function.
can you give me any suggestion.
With Regards,
R.Sundaram.
|
|
|
|
|
how to get software package for vc++ project exe
|
|
|
|
|
Are YOu looking for Some Type of Installer.
Grab it from here INNO Setup
[^].
It's FREE
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello ,
I want to give the int code and get string instead.
You know that 65 is A and...
I want this function for unicode keys.
Best Wishes,
Thanks.
|
|
|
|
|
I need to do some clean up work before my MFC SDI program exits. How and where can I break into the program to do these things. I need to close a serial port in particular.
Thanks
John
|
|
|
|
|
Where is the handle of your COM port stored ? You can close the port in the destructor of the class that contains this handle for example.
Or you can override the ExitInstance from your CWinApp class and close it there.
Hope this helps
|
|
|
|
|
hi all,
I am using Text boxes to MFC Dialog base Applcation.But I can not change the Color Scroll bars which appear with TextBoxes,ListBoxes like that..
How do I do that?
if any one this pl reply me..
Thanks in advance..
|
|
|
|
|
How to call javascript in mfc project without CHtmlView?
I have a source code implement IDispatch by CHtmlView,
but in my project I don't need it.
Thanks!
|
|
|
|
|
Sounds like you need to look at Active Script Host.
onwards and upwards...
|
|
|
|
|
Hi
I am working with Win32 serial communication programming in vc++. I was asked to use sliding window method here, but I am totally new and have no idea about this sliding window consept.
Can anyone please help me by giveing me some information on sliding window and its implementation algorithm and how it can be used in serial communication.
I would be of great help to me if any one can give me some inputs.
Thanks
Madhavi
|
|
|
|