|
|
hi friends,
i have have a MDI Application. when i close a document using onclosedocument. my document handle remains active though the members used in document are set to null. so i cannot check this condition
if(doc)
as it returns true. whereas in the if block it cannot access the members so app crashes
eg.
<pre>
if(doc) //handle =FAEX000
{
doc->getprivatevariable_or_functions(); // the application crashes here
}
</pre>
thanking in anticipation
REgards
Samir
|
|
|
|
|
When you close your document set the variable to NULL to indicate that it no longer exists.
I must get a clever new signature for 2011.
|
|
|
|
|
OK, the really hot chicks part was just a joke.
Seriously, I have an ATL COM server that runs as a service. The ATL server is run as a singleton (REGCLS_MULTIPLEUSE). I've got a series of "client" apps (on the same machine) that send the server some data. When the server is shutdown, I want to send an event to the clients. Since I'm using COM I figured I'd use connection points. The server does this with ATL's IConnectionPointContainerImpl, and their proxy class wrapper around the dispatch event interface. I can see that the client properly registers with the server. But when the server tries to call back the client interface, it get's an error, and the client gets an access violation.
Is there some obvious step I've missed? On the client side I'm using ATL's IDispEventImpl to implement the dispatch interface callback.
|
|
|
|
|
Add Your code and error description, please
|
|
|
|
|
Hi,
I'm slowly getting into GUI Development and made first experiences with C++/Qt4 which I really like.
I focus on OSX Development so I decided to give a try to Xcode and Cocoa too. I tried the first tutorial where u build a simple currency converter. And I'm finding this very confusing. Am I really forced into using this Interface Builder App?
I think that GUI Development with Qt is much better to learn and faster to code and I have a much better overview over my Interface and all those signals, slots, senders and so on if I don't have to use those object inspectors just to check what object is connected to what...
What do you think? Should I give XCode another try or do you share my first impression?
|
|
|
|
|
I was using XCode to do iPhone development and found it to be a challenge as well. What I did is to change to use MonoTouch (.NET) for iPhone development. There actually is a version of Mono that works pretty well on the Mac if you are a .NET programmer. Knowing Obj-C is not a bad thing, but it is not that fast when you are used to other things.
Other people have done their Mac apps with Air or Java. I know Qt is definately faster for most people starting out than Obj-C is. So if you do not want to use Air, Java, or Mono, then I would say Qt will be faster, but having the knowledge of Obj-C is good as well since alot of the sample code out there for a Mac is written in Obj-C.
Steve Maier
|
|
|
|
|
Hi guys, am in a MFC project for that i need to notify my client when any data is updated or inserted in my server database.
I am using CSocket for server client connections, how can i identify the change and how to notify my client that's my problem.I am beginner in MFC .
If you know pls guide me .
Thanks in advance
ganesh_IT
|
|
|
|
|
What's the lightest and easiest way to pass a message from on thread to another? The sender thread must be able to do this asynchronously so there's no to minimal time delay. The receiving thread will retrieve the thread and write it to a file. The goal here is to concentrate the hiccups associated with disk i/o to the one logging thread, so that the other working threads are not hiccup prone. It's okay that the logging thread is hiccup prone since that is all it's responsible for.
Thanks for any help with this.
|
|
|
|
|
Say you have a structure like so, accessible by both threads as a global variable:
typedef struct {
void *data;
void *next_block;
}block;
The idea is to have a list of data blocks, each with a pointer to the data to be written to file, and a pointer to the next data block to be written.
The sender thread will do its work, and every time data has been generated, it will allocate a new block and add its address to the next_block member of the previously last block. The next_block member of the newly added block is set to null.
The receiver/writer thread will start at the beginning of the array and continuously check if next_block has been changed from a null-pointer to something else. When it's no longer null, the sender thread must have added data. This new data is written to file and may be free'd in memory. The block struct which data was written before this block's data may also be free'd now.
After this, the check loop on next_block will continue, based on the last written block.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Thanks, I like this solution. Additionally I'd need to manage shared access with mutexes.
|
|
|
|
|
That shouldn't even be necesary in this case:
If you make sure a block is initialised (data pointer valid, next_block pointer initialised) before it's appended to the list by the sender thread, it can't cause multithreading problems since the actual appending action is just one assignment.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
It has been awhile since I've looked this deeply into things. Is the following a good way to convert from a wstring to a string?
std::string dwl::convertWstrToStdString(const std::wstring & wStr) {
const std::locale & loc = std::wcout.getloc();
std::string str;
str.resize(wStr.size());
std::string::iterator it = str.begin();
for (std::wstring::const_iterator wit = wStr.begin(); wit != wStr.end(); ++wit) {
*it = std::use_facet<std::ctype<wchar_t> >(loc).narrow(*wit);
++it;
}
return str;
}
Or is the 'str.resize' note (or something else) going to bite in the future? Will the str iterator correctly increment if the character it points to will be a Multi Byte character? Should I just use WideCharToMultiByte() and massage it into a std::string?
Thanks,
David
|
|
|
|
|
After more searching, I went with the following. CStrWrap is just a thin wrapper around a char array, with a destructor that frees the memory.
std::string dwl::convertWstrToStdString(const std::wstring & wStr) {
if (wStr == L"" || wStr.size()==0) return "";
int origSize = wStr.size();
origSize++;
DWORD conversionFlags = 0;
int requiredSize = WideCharToMultiByte(CP_ACP, conversionFlags, wStr.c_str(),
origSize, NULL, 0, NULL, NULL);
if (requiredSize == 0)
throw DwlException(_T("Bad Wide String to String conversion"));
CStrWrap cStr(requiredSize+1);
int result = WideCharToMultiByte(CP_ACP, conversionFlags, wStr.c_str(),
origSize, cStr[0], requiredSize, NULL, NULL);
if (result==0) throw DwlException(_T("Error converting string"));
*cStr[result] = '\0';
return std::string(cStr[0]);
}
If anyone sees any issues with it, please let me know. Thanks!
EDIT - And for std::string to std::wstring:
std::wstring dwl::convertStdStringToWString(const std::string & str) {
if (str.length() == 0) return L"";
int unicodeLength = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), 0, 0);
++unicodeLength;
if (unicodeLength == 0) throw DwlException(_T("Empty conversion"));
MbStrWrap wStr(unicodeLength);
int result = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), wStr[0],
unicodeLength);
if (result==0) throw DwlException(_T("Error converting string"));
*wStr[result] = L'\0';
return std::wstring(wStr[0]);
}
My website :: The astronomy of our ancestors: Book :: Videos
modified on Sunday, January 9, 2011 1:28 AM
|
|
|
|
|
You can easily convert if you use an intermediate class like CString or _bstr_t .
Using CString -
wstring wstr(L"Wide String");
CStringA cstr(wstr.c_str());
string str(cstr);
str = "String";
CStringW wcstr(str.c_str());
wstr = wcstr;
Using _bstr_t ;
_bstr_t bstr1(wstr.c_str());
str = (char*)bstr1;
_bstr_t bstr2(str.c_str());
wstr = (wchar_t*)bstr2;
|
|
|
|
|
Thanks. I wasn't aware of those possibilities.
|
|
|
|
|
i think we need to set correct locale first (setlocale) , right ?
If u can Dream... U can do it
|
|
|
|
|
If you do not specify a locale, the default will be used.
|
|
|
|
|
Hello all. I've recently been digging around the job market and several times I've come across programmer positions that are asking for candidates with experience in "STL relational database" development. I'm wondering what exactly is meant by that? In my exposure to STL in general I don't recall coming across anything akin to .NET classes such as DataTable, DataRow, DataSet, etc... So when an employer makes this request, what are they looking for? I can think of two possibilities:
1. Just looking for someone who knows how to establish ODBC connections with STL to retrieve data from a data source (SQL Server, MySQL, Oracle, or whatever) and populate simple STL data structures like Lists.
2. Use simple STL structures to actually program an entire database-like series of interrelated classes so that no database is even needed on the back end.
Can anyone clarify this for me? Also, can anyone point me to a good, *in-depth* STL resource (websites or published books)?
Thanks for reading!
|
|
|
|
|
I can't be sure but perhaps this[^] is what you are looking for.
I must get a clever new signature for 2011.
|
|
|
|
|
That sounds really intriguing and I'd love to read it, but $80 (Amazon Marketplace) for a mere 150 pages is terribly steep.
|
|
|
|
|
Hi,
I have an MDI application that call a dialog in dll by passing the handle of parent A_hWndParent.
the dll receive this handle and create an instance of my dialog ( Login dialog (security) ) and set A_hWndParent as its parent like this :
MyDialog Dlg;
Dlg.SetParent(A_hWndParent);
Dlg.DoModal();
But when lunching application and switch window to an other window( like Notepad++ ) and return to it I can manipulate the parent application without login (parameters login ok in the dialog) which is not logic
NB: the parameter A_hWndParent is managed correctly in the parent application and is passed correctly to the dll.But it seems not correctly managed in the dll.
there is something wrong in my code ie there is a problem in SetParent function?
|
|
|
|
|
Try passing the parent window to to CDialog's constructor, when creating MyDialog object.
See here
More over, is it your own SetParent function which takes HWND as parameter?
|
|
|
|
|
The solution is to pass the HWND parent as parameter to DoModal() instead ::GetActiveWindow().
Thank you for help.
|
|
|
|
|
I'd like to be able to change the style of a DateTimePicker control at runtime. Normally I would expect something like this to work just fine (as it does with the Listview control)
void DateTimePicker::setUpDownControlsVisible( const bool& val )
{
LONG_PTR style = ::GetWindowLongPtr( hwnd_, GWL_STYLE );
if ( val ) {
style |= DTS_UPDOWN;
}
else {
style &= ~DTS_UPDOWN;
}
::SetWindowLongPtr( hwnd_, GWL_STYLE, style );
::SetWindowPos( hwnd_, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
InvalidateRect( hwnd_, NULL, TRUE );
}
However when this is executed there is no change in the control. Is this not allowed for the date time control, or is there something else you need to do here?
|
|
|
|