|
dilara semerci wrote: i am trying to use SHGetFolderPath and i get " error C3861: 'SHGetFolderPath': identifier not found" , i have included the #include "Shlobj.h"...
But have you ensured that _WIN32_IE is greater than or equal to 0x0500 ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
yes, i had and it works fine now
|
|
|
|
|
In a dialog base application i want to use a SDI application.
A SDI application display some data in its view window.
What i want, i want t display this view window data on dialog box.
SDI application is container type application which use coledocument andits related classes.
If it'snot possible then can i achive the same in activex control or dll
Please suggest.
|
|
|
|
|
You should use an SDI application with the view class derived from CFormView .
Now you will be able to use the dialog template to place controls on the dialog and this will appear as the view.
|
|
|
|
|
please give any sample link if available
|
|
|
|
|
You should be able to find plenty of examples using google.
|
|
|
|
|
Dear all,
I getting an exception error when file is missing or corrupted after it has been opened via CFile class. Below is the scenario.
Scenario:
1. Open file via CFile. (file is exist)
2. to simulate file corrupted (manually forced to delete it)
3. exception occurred.
CFile file;
file.Open("C:\log.dat",CFile::modeWrite|CFile::modeCreate, NULL);
file.Close();
I also tried using file.Abort(), but also getting an exception error.
Is there any proper handling if the file is missing or corrupted after opened and before it close?
Thanks in advance.
Regards,
Wee Chong
|
|
|
|
|
Use the CFile::shareExclusive mode as described in MSDN[^] to prevent other processes from accessing your file.
It's time for a new signature.
|
|
|
|
|
Hi Richard,
Thanks for your reply. Your solution can prevent the file access/deleted by other program. The problem I faced is the file corrupted or missing due to hard drive issue. The exception is occurred when trying to execute File.Close().
|
|
|
|
|
There is nothing you can do by programming if you have hard drive problems, other than maybe catching the exception and trying to save your environment. However, in cases like this it is likely that the entire system will fail.
It's time for a new signature.
|
|
|
|
|
I have an MDI project based on CScrollView , and on there I have an CRectTracker object. When track the CRectTracker object out of visible area , and scrolls is moved by user , CRectTracker object keep old position , not new position ... sample code could be taken from here , is named TestTracker2.rar ... or , anybody know an sample implementation of CRectTracker in CScrollView class ?
modified on Tuesday, August 10, 2010 5:49 AM
|
|
|
|
|
Hi!
I've given a string like this:"S R Tendulkar". I've to get the third part in the string ie "Tendulkar" and randomly rearrange or replace the characters between 'd' to 'r'. ie I've to display "SR Tendulkar" as "S R Tendalkur" or as "S R Tendelker". My string is a std::string. How to do this?
|
|
|
|
|
std::transform will do the trick with the right functor. If you just want to randomly jumble the characters in the range std::random_shuffle will work as well.
Looking at your examples it looks like you only want to fiddle with the vowels so std::transform is the way to go.
Cheers,
Ash
|
|
|
|
|
Hi!
I've declared the string like this:
std::string test = "S R Tendulkar";
If I call, test.transform(); or test.random_shuffle(); , I got the following errors:
1>d:\test\main.cpp(53) : error C2039: 'transform' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>d:\test\main.cpp(54) : error C2039: 'random_shuffle' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
How to call the functions?
|
|
|
|
|
They're not members of std::string - they're defined in <algorithm> .
std::transform takes a range over which you want to do something, a destination and what you want to do. So if you wanted to convert all vowels to the next in a sequence you could do something like:
std::pair<char, char> vowel_step =
{
std::pair<char, char> ( 'a', 'e' ),
std::pair<char, char> ( 'e', 'i' ),
std::pair<char, char> ( 'i', 'o' ),
std::pair<char, char> ( 'o', 'u' ),
std::pair<char, char> ( 'u', 'a' )
};
std::map<char, char> vowel_map( &vowel_step[ 0 ], &vowel_step[ 5 ] );
class vowel_transformer
{
public:
char operator()( char c )
{
std::map<char, char>::const_iterator iter( vowel_map.find( c ) );
if( iter != vowel_map.end() ) return iter->second;
return c;
}
};
std::string aesc( "aescleal" );
std::transform( aesc.begin(), aesc.end(), aesc.begin(), vowel_transformer() );
That should convert "aescleal" into "eiscliel". To get the effect you want define a class to do the tranformation on a per-character basis and work out the range you want to operate on.
Cheers,
Ash
PS: If you're using C++0x you can simplify a lot of the boiler plate.
Edited as I'm a crap proof reader
|
|
|
|
|
Hi Ash,
I found your post very intresting and published at my website http://www.visualcpp.org/?p=368[^]. please check if you ok with it otherwise i can remove it, if you don't like it
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Any messages I post here are fair game for reuse/reposting - if I didn't want other people to use what I wrote I wouldn't post it here!
Glad you found it interesting as well.
Cheers,
Ash
|
|
|
|
|
Hi all,
what is the max rows and max column size of the CListControl?
|
|
|
|
|
Since the documentation doesn't say anything about the maximum limits, I guess it would either depend on the available process memory or the maximum value an int can hold since the index is specified using an int variable.
|
|
|
|
|
When an app crashed, VC displayed a message:
The instruction at "0x00123456" referenced memory "0x00654321" could not be read.
If the error caused by a pointer, I guess, the second value "0x00654321" is the pointer value (such as CWnd*pc; value is (int)pc ), and first value "0x00123456" is memory address where the pointer resides.
Is it correct?
|
|
|
|
|
includeh10 wrote: Is it correct?
Almost. The second number is the address referenced, which bears a relation to the pointer, but is not necessarily exactly the same. For example, a->b uses a pointer of value a , but the actual location referenced is offsetof(the_struct, b) higher. The first number is the address of the failing instruction, which is almost certainly NOT where the pointer lives. The preceding instruction(s) probably fetch or calculate the pointer value to use.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
The error message means exactly what it says - whatever instruction the processor was executing when the instruction pointer hit 0x00123456 caused the problem. The problem was that it tried reading something at an address of 0x00654321 which wasn't a lump of memory it could read.
So it could be loads of things:
- you tried casting something you shouldn't to a pointer and the variable you cast had a value of 0x00654321
- a pointer contained a value of 0x00654321 and you tried dereferencing it
- you scribbled all over memory using memset and managled a pointer
- you scribbled all over memory and managed to corrupt a thread's stack
- you're trying to use memory that you've freed
- you're accessing a local variable after it's gone out of scope
Whatever it is it's pretty insanitary and might have the unfortunate effect of moving around in memory when you're trying to find it. You might even think you've fixed it when all you've done is move it so that when a customer or professor runs it they find it
To stop this sort of thing happening:
- don't manually manage memory
- don't manually manipulate memory (memset, memcpy, that sort of thing)
- don't use pointers
Cheers,
Ash
|
|
|
|
|
Hi,
CDC* pDc = GetDC();
CSize cSize = pDc->GetTextExtent( "1", 1 );
CRect cRect ( 0, iPadding, cSize.cx, cSize.cy );
pDc->DrawText( "1", 1, &cRect , DT_CENTER|DT_VCENTER|DT_NOCLIP );
The above code displays the text "1" horizontally in cRect .
To display the text vertically, i did as follows:
CFont newFont;
newFont.CreateFont(24, 0, 900, 900, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
CFont* pFont = pDC->SelectObject(&newFont);
pDC->DrawText("1", 1, &cRect, DT_CENTER|DT_VCENTER|DT_NOCLIP);
pDC->SelectObject(pFont);
newFont.DeleteObject();
But in this case, I couldnt get any text displayed.
Please can someone help me to get the text displayed vertically. How should cRect be manipulated to draw the text vertically?
Mary
|
|
|
|
|
Did you see here or here?
Have you tried playing with different CRect values? You've probably just made the drawing area too restrictive.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
hey guys i am taking some parameters from an initialvalues.ini file and write the new values in it too for the upcoming times. I have learned read/write the .ini files in vc++ and my program works fine with these codes:
[code]
GetPrivateProfileString(_T("Settings"), _T("File_List"), _T("") ,lastsession, 255,
_T("C:\\Documents and Settings\\stajyervestek1\\Desktop\\Copy of Dilara\\Dilara\\initial_paths.ini"));
.
.
.
WritePrivateProfileString(_T("Settings"), _T("File_List"), m_list,
_T("C:\\Documents and Settings\\stajyervestek1\\Desktop\\Copy of Dilara\\Dilara\\initial_paths.ini"));
[/code]
However, i want this program to work in other circumstances, too. mainly, i want this "C:\\Documents and Settings\\stajyervestek1\\Desktop\\Copy of Dilara\\Dilara" part to be the home directory of the user. I tried to write .\\ instead but the program crashed when i tried to use "writeprivateprofilestring". Can you give me any advice to achieve my goal?
thanks in advance
|
|
|
|
|