|
Look at the WM_QUERYENDSESSION and WM_ENDSESSION messages.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
There is a application with multiple document support(A document is associated with a few kind of views and managed by CMultiDocTemplate).If i open a new document and then close it for many times, i can’t open any window finally, even opening a pop-up menu in another process is unavailable. I think it due to the following code.But i don't know why it works well at the beginning. Is there a resource leakage?
Thanks for your help!
<br />
void CMultiDocTemplate::LoadTemplate()<br />
{<br />
CDocTemplate::LoadTemplate();<br />
<br />
if (m_nIDResource != 0 && m_hMenuShared == NULL)<br />
{<br />
HINSTANCE hInst = AfxFindResourceHandle(<br />
MAKEINTRESOURCE(m_nIDResource), RT_MENU);<br />
m_hMenuShared = ::LoadMenu(hInst, MAKEINTRESOURCE(m_nIDResource));
m_hAccelTable =<br />
::LoadAccelerators(hInst, MAKEINTRESOURCE(m_nIDResource));<br />
}<br />
<br />
#ifdef _DEBUG<br />
if (m_hMenuShared == NULL)<br />
TRACE1("Warning: no shared menu for document template #%d.\n",<br />
m_nIDResource);<br />
#endif //_DEBUG<br />
}<br />
|
|
|
|
|
1814 The specified resource name cannot be found in the image file.
ERROR_RESOURCE_NAME_NOT_FOUND
Carl
|
|
|
|
|
Thanks for your help!
Yeah, Code 1814 means can't find the resource in the image file, but in fact the function "LoadMenu" works well at the beginnig. The question is that it doesn't work after many openning and closing document operation. Does this problem due to resource leakage?
|
|
|
|
|
Waiting for your help!Thanks!
|
|
|
|
|
YunYan wrote:
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(m_nIDResource), RT_MENU);
Does hInst have a non-NULL value prior to calling LoadMenu() ?
YunYan wrote:
m_hMenuShared = ::LoadMenu(hInst, MAKEINTRESOURCE(m_nIDResource));
m_hAccelTable = ::LoadAccelerators(hInst, MAKEINTRESOURCE(m_nIDResource));
Do you also have corresponding calls to DestroyMenu() and DestroyAcceleratorTable() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I'm using rundll32 to run a dll that has no need for a main app. However i need to trap when windows is being shut down to serialize data. In the past i've used WM_QUERYENDSESSION in the main win proc.
Is there a way of trapping this message from a dll?
How else could this be acheived?
Thanks
Carl
|
|
|
|
|
when i programaticaly press button by
SetState(TRUE)
and user leaves it using tab-key
button executes command (the same action like button press by user)
-> how to avoid this call? (i need this command when user clicks on button only (or uses keyboard to press it))
thanks for reply
t!
|
|
|
|
|
Hello,
I'm writing a C# application using managed and unmanged c++ libraries.
I have a bug, which causes an assertion "_BLOCK_TYPE_IS_VALID".
The message appears always in a different places.
Exceptions handling is not helping. Where to look?
|
|
|
|
|
Hi,
I am trying to get the connection status of my ODBC connection to MySQL in a VC++.Net project, by retrieving the "SQL_ATTR_CONNECTION_DEAD" attribute using the SQLGetConnectAttr function.
But whether the MySQL server is running or not its always returning 0 which implies SQL_CD_FALSE (i,e. the connection is still active.)
I made the connection as folows:-
SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(void *)SQL_OV_ODBC3,0);
SQLAllocHandle(SQL_HANDLE_DBC,henv, &hdbc);
SQLConnect(hdbc,pmydsn, SQL_NTS, pmyuid, SQL_NTS, pmypwd, SQL_NTS);
Now after this connection is established I try to get the status by calling the following function;
SQLGetConnectAttr(hdbc,SQL_ATTR_CONNECTION_DEAD,&value,sizeof(SQLINTEGER),&strln);
I get back value = 0 implying the connection is still active.
now i manually stop the MySQL server from the command prompt and again execute the same function but i still get back value = 0 .
Can u help me to figure out where i m going wrong and making a blunder.
ur prompt reply is highly recommended
Nitin Bansal
|
|
|
|
|
Hi everyone!
First, I appologise for my last post !
Anyway, got this here code in main():
int number1 = 5;<br />
int number2 = 10;<br />
<br />
int *p_number1 = &number1;<br />
int *p_number2 = &number2;<br />
<br />
int *arrayAddress;<br />
int *pointerArray[2];<br />
<br />
pointerArray[0] = p_number1;<br />
pointerArray[1] = p_number2;<br />
<br />
cout << " Pointer array at [0]: " << pointerArray[0];<br />
cout << endl;<br />
cout << " Pointer array at [1]: " << pointerArray[1];<br />
<br />
cout << endl;<br />
cout << endl;<br />
<br />
cout << " Pointer array deref at [0]: " << *pointerArray[0];<br />
cout << endl;<br />
cout << " Pointer array deref at [1]: " << *pointerArray[1];<br />
<br />
cout << endl;<br />
cout << endl;<br />
<br />
arrayAddress = pointerArray[0];<br />
<br />
cout << endl;<br />
cout << " Array address: " << arrayAddress;<br />
cout << endl;<br />
cout << " Array access through address: " << arrayAddress[0];
It compiles and the last statment prints 5 the actual value at the address that is stored in pointerArray[0] . But if I was to put arrayAddress[1] I get garbage.
Question: I have a class that contains the above code, or an array that points to a bunch of variables. Is there a way to pass the name of the array
outside the class private: to main() and then access it as if i was inside the class.
I am asking because I have a class private: filled with 24 variables, and got 24 members in public: that can return the current value of those variables. To shrink the class I decided to make an array of pointers to those variables and pass it outside the class so that instead of using the member functions I would lookup/change values directly thru the array of pointers.
If you have another solution to this problem PLEASE HELP!
Thanks for your time!
|
|
|
|
|
This is wrong in so many ways.
To answer the last question first - try writing an [] operator for the class to give access to the variables in the class. Then you can do things like boundary checks for the index etc, and you won't be directly exposing private data.
As for the actual code you wrote.
arrayAddress = pointerArray[0];
makes arrayAddress point to number1 .
Writing arrayAddress[0] dereferences the pointer to get the value of number1.
Writing arrayAddress[1] dereferences a pointer one integer past the memory location of number1, number2 might be stored there but probably not. You need to check your usage of pointers.
|
|
|
|
|
Mike Beckerleg wrote:
This is wrong in so many ways.
You are right!
But I found the code bellow to work just right:
void arrayAddressFunct(int *array[], int index)<br />
{<br />
cout << endl;<br />
cout << " Array address: " << array;<br />
cout << endl;<br />
cout << " Array access through address at index: " << *array[index];<br />
};
If the pointerArray address is passed to first argument and the desired index to the second then the function has access to the array at any index. It can actualy be used to return/change the values pointed to by the array.
This is what I wanted to do in the first place.
A question though: Is it a good idea to do the following?
Say a got a class/etc. containing a bunch of variables and I declare an array pointing to those variables. Then I write a two members which when accessed outside of the class in the form described by the code above can change and return the variables pointed to thru the array.
Or is there a better way to keep the variables safe but still have access to them without having to write a pile of members for access/change/return of the values.
|
|
|
|
|
I'm a bit confused about what you are trying to achieve but here goes.
If your class contains an array of values that you want to be able to access then write an operator[] method such as:
<br />
class SomeClass<br />
{<br />
public:<br />
<br />
const double& operator[](const int index) const<br />
{<br />
return mArray[index];<br />
}<br />
<br />
double& operator[](const int index)<br />
{<br />
return mArray[index];<br />
}<br />
<br />
private:<br />
double mArray[30];<br />
};<br />
Obviously you would put in some sort of bounds checking on the index value.
However from what you are saying the values you are trying to access are not currently in an array, why not? What are these data items? It sounds like they are unrelated items and you just want the array to save having to write accessor methods. If that is the case you may as well just make them public which is what your method would do!
|
|
|
|
|
Thanks for your time!
I know the questions are a bit $#@^ed up, but I'm just a newb!
I sorted the whole mess out, I got the class to do what I want and it is now like 20 times smaller .
Once again thanks for your help!
|
|
|
|
|
Hi!
I have a known URL on my cpu, for e.g. “C:\Temp\myFiles” that contains some files. I’d like to make a zip-file of all the files. If possible also zip the “myFiles” folder and all its containing files.
_____________________________
...and justice for all
APe
|
|
|
|
|
|
HI,
I want to handle a device through a web page.
means a i open a web page and i will give an IP ( and Socket if neccessry )in it
it will send data to IP where my device is.
and aslo recive data from that and display it in web page
what is a right way to do this.
1... Using COM DLL on Server where Web page resides.
2... OR made Web Services ( as of Dot Net). that handles these activites.
or there is any other way to do this.
any sample etc ...
thanx
Regards.
|
|
|
|
|
Hi
I have few edit boxes in a Dialog window.
Now I want to process the characters entered in each edit boxes.
I dont want to use OnChar or OnKeyDown becouse it will process all those messages to the main window. I just want to process the messages only when user types something in the edit box. How can I do that.
btw: this is for finding some unwanted characters like @#@#!@$ being entered in the certain edit box.
Thanks
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hi,
One solution is to implement the WM_CHANGE message. Each time it is called you will check the edit boxes...
Well... I am a beginner ...
|
|
|
|
|
Hi
Thankyou.
It will work. But I want to get each character by character entered into the edit box.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
maybe you should read an article about a validating edit control?
click me
|
|
|
|
|
Enhanced Focus Edit Control with Input Filtering
[^]
My control does filtering of input (also via paste operations). IIRC, I could not get the WM_CHAR message to reflect from the control, so I used PreTranslateMessage on the edit control class itself, so I would only get WM_CHAR messages for that control.
Peace!
-=- James
Tip for inexperienced drivers: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
Hi
I tried it but I was concerned about the processing.
Anyway I think I will be doing this
Thankyou for putting up suggestion
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hi Friends,
There are lot many articles available on message routing.Still I am having some basic quries:
please consider 2 cases for messages (windows messages & Command messages)
Q 1. In SDI/MDI, how routing takes place?
Q 2. In case of command message if a class is handling that, What about other classes in route.
Q 3. It seems that, some messages are not handled by framework, I did not get them even after installing windows hooks (like WM_LBUTTONDOWN on caption bar) Why it so?
Vikram S
|
|
|
|