|
Can anyone please tell me why this isn't working? It compiles fine and runs, but the close button doesn't get "greyed out".
#include "stdafx.h"
#include "CELL v2.h"
#include "windows.h"
#include "tchar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
using namespace std;
CWinApp theApp;
char buf[100];
void CloseMenu(){
wsprintf(buf,_T("CELL"));
SetConsoleTitle((LPCTSTR)buf);
HWND hwnd=NULL;
while(NULL==hwnd)
hwnd=::FindWindowEx(NULL,NULL,NULL,(LPCTSTR)buf);
SetConsoleTitle (_T("CELL"));
HMENU hmenu=GetSystemMenu(hwnd,FALSE);
DeleteMenu(hmenu,SC_CLOSE,MF_BYCOMMAND);
}
int _tmain(int argc,TCHAR* argv[],TCHAR* envp[]){
int nRetCode=0;
if(!AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)){
cerr<<_T("Fatal Error: MFC initialization failed")<
|
|
|
|
|
You might just need to redraw the frame. Try manually switching to another window then switching back to your console to see if it's really getting grayed out or not. If you want to do it from code (the code I posted you yesterday had this call in it):
::SetWindowPos( hwnd, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_DRAWFRAME );
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
I'm trying to get values out of the registry, using CRegKey, and I'm able to get number and string values from the registry, but when ever I try to QueryValue a binary value the QueryValue fails. I can't seem to get it to work no matter what I try.
Thanks in advanced
There's always one more bug.
|
|
|
|
|
What's the return value from RegQueryValueEx()? Post code.
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Well, I was using the MFC class CRegKey. The problem is more I dont know what type of variable to use that the QueryValue function would put the binary data into.
For example, to get a string, i do this:
<br />
CString str;<br />
if( key.QueryValue( str.GetBuffer(pwcount), branch, &pwcount)==ERROR_SUCCESS )<br />
{<br />
str.ReleaseBuffer();<br />
return str;<br />
}<br />
and to get a number, i do this:
<br />
DWORD dwValue;<br />
CString str; <br />
if( key.QueryValue( dwValue, branch)==ERROR_SUCCESS )<br />
{<br />
str.Format("%i", dwValue);<br />
return str; <br />
}<br />
In both of those example key and branch are sent to the function and I'm pretty sure the problem doesn't lie within them. I'm really just not sure how to get the binary data into a variable.
Maybe going the non-MFC route would be better?
Thanks,
Steve
There's always one more bug.
|
|
|
|
|
It would help if you knew how the data was written to the registry. That way, the same format can be used to retrieve the data.
In one of my apps, I write some binary data using the following:
long lColumns[20];
...
lResult = RegSetValueEx(hKey, "Columns", 0, REG_BINARY, (LPBYTE) &lColumns[0], sizeof(lColumnIds));
If I was to try and pull that data out without any knowledge of how it was written, I'd be in for a lot of work. Since I do know the format, I can simply use:
dwBufferSize = sizeof(lColumns);
lResult = RegQueryValueEx(hKey, "Columns", NULL, NULL, (LPBYTE) lColumns, &dwBufferSize);
CRegKey is a neat class and all but I stopped using it a few years ago because I couldn't guarantee it would work in all necessary environments. Read the MSDN article Q190686 for details.
|
|
|
|
|
I am using a virtual list control, in the message LVN_GETDISPINFO i am setting the text but how can i set the ItemData.
ON_NOTIFY(LVN_GETDISPINFO, ID_LIST, GetDispInfo)
void CWndEx::GetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem= &(pDispInfo)->item;
if (pItem->mask & LVIF_TEXT)
{
//Comes here
}
if(pItem->mask & LVIF_PARAM)
{
//NEVER COMES
}
}
When i call m_ListCtrl.GetItemData(nRow) it allways returns 0 and never comes to the GetDisplayInfo function. Do you set the ItemData some other way or just handle getting the ItemData in your own function?
Any Ideas?
|
|
|
|
|
I don't believe you can set the item data using callbacks. Only the text and image index can be set that way. You would set the item data either whenever you add the item to the control (InsertItem) or with SetItemData after it's added.
|
|
|
|
|
Dear all,
All I'm trying to do is to enter 3 books from the keyboard to an array and then traverse the array to display the elements and also prompt the user to enter the book names to delete them from the array(if the book exists into the array).
The code that adds to the array is:
<br />
template<class Object><br />
void List<Object>::addElement(char* type)<br />
{<br />
if (this->num_elements == MAX_ELEMENTS)<br />
{<br />
cout<<"No more room in the "<<type<<" array.\n";<br />
cout<<"The maximum number of "<<type<<" is "<<MAX_ELEMENTS<<"."<<endl;<br />
}<br />
else<br />
{<br />
this->element_list[num_elements]=new Object;<br />
(this->num_elements)++;<br />
}<br />
}<br />
The code that displays the elements is:
<br />
template<class Object><br />
void List<Object>::displayElements(char* type)<br />
{<br />
if (num_elements == 0)<br />
cout<<"No "<<type<<" is found in the "<<type<<" array.\n";<br />
else<br />
for(int element=0; element<this->num_elements; element++)<br />
{<br />
cout<<'\n';<br />
this->element_list[element]->display(association_list.get_data(element_list[element]));<br />
}<br />
}<br />
The code for deleting is:
<br />
template<class Object><br />
void List<Object>::removeElement(char* type)<br />
{<br />
char* item;<br />
if (this->num_elements == 0)<br />
cout<<"There are no "<<type<<"s to delete from the "<<type<<" array."<<endl;<br />
else<br />
item=get_string_ver2("Input element to delete: ");<br />
for(int element=0; element<this->num_elements; element++)<br />
if (strcmp(item,element_list[element]->get_data()) == 0)<br />
element_list[element]='\0';<br />
else<br />
cout<<"Element not found\n";<br />
}<br />
But there is a problem after deleting a book from the array.
I can't display the elements of the array, after a book has been deleted. For example if I enter a, a as the first book and b, b as the second book and then after deleting b, b, try to display the books into the array, I will only see the details of the first book and after that the program will be terminated due to an error. The error occurs at the file:
<br />
Book.cpp<br />
Book::Book()<br />
{<br />
cout<<"Book constructor called called\n";<br />
this->bookDetails=get_string_ver2("input book title and author separated by a comma and a space character: ");<br />
}<br />
<br />
Book::~Book()<br />
{<br />
if (this->bookDetails)<br />
delete [] this->bookDetails;<br />
}<br />
<br />
<br />
void Book::display(Member* borrower)<br />
{<br />
cout<<"Book title and author are: "<<this->bookDetails<<"."<<endl;<br />
if (borrower)<br />
cout<<"The member's name is: "<<borrower->get_data()<<"."<<endl;<br />
else<br />
cout<<"No member has borrowed a book."<<endl;<br />
}<br />
in the first line of code of the display function.(cout<<"Book title ....)
What is wrong?
If you need more details or anything more about the program, please let me know.
Regards,
grscot
|
|
|
|
|
1) the pre and code tags wrap around the code, not your explanatory comments.
2) You need to use the Formatting bar lt and gt to replace all lt and gt characters. Your for loops aren't displaying these operators.
3) In removeElement() you have:
element_list[element]='\0';
you aren't removing the item from the array, nor are you deleting it, resulting in memory leaks.
4) In displayElements()
this->element_list[element]->display(association_list.get_data(element_list[element]));
will raise an exception after your delete because:
this->element_list[element]->
is a NULL pointer for the deleted item. You should always test for NULL in cases like this, before attempting to use a pointer.
5) Why are you using this-> everywhere?
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
grscot wrote:
element_list[element]='\0';
You are setting this element to NULL, so somewhere in the function display which you call it like this:
this->element_list[element]->display(association_list.get_data(element_list[element]));
you are trying to access this NULL pointer. It would be a good idea to post the code for the display function and also for association_list::get_data( class Object );
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
How to use modem the way Hyper Terminal does it?
|
|
|
|
|
Use an OLE/ActiveX/COM control like SaxSoft's SaxComm.
Jason Henderson My articles
"The best argument against democracy is a five-minute conversation with the average voter." - Winston Churchill
|
|
|
|
|
Can anyone give a link to any useful article?
|
|
|
|
|
This sounds like a rewording of another post on modems.
Look up TAPI on the MSN Library or look for a book on the subject.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hi,
Is there anyway to get the keyboard input eg check if CTRL + A is pressed, while the program does not have focus?
thanks alot
|
|
|
|
|
GetKeyState() & GetAsyncKeyState() return with hi-bit set if key was down. If they don't work then a keyboard hook maybe the only way.
Please don't be Anonymous.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
What is Anonymous up to!
Your answer is to 'Anonymous' is correct but first he needs to receive a messages (other than paint). If he wants to know the key state when his program [or window] does not have the focus, then he will have to set up a timer processor to call GetKeyState() [and or GetAsyncKeyState()] so that he can monitor the status of the keyboard.
Trust in the code Luke. Yea right!
|
|
|
|
|
Anyone know how the skinning engine was designed?? How does the main app start and basically load a skin as the default UI?
|
|
|
|
|
Does anyone know how to get the handle to a pane in the status bar?
Thanks
|
|
|
|
|
Are you using MFC? If so, use the m_wndStatusBar object. It belongs to the CFrameWnd-derived class.
If you are trying to add something to one of the panes, examples are plentiful here, and from MSDN.
|
|
|
|
|
Yes, I am using MFC. The m_wndStatusBar gives me the CStatusBar, but I need a handle to one of the panes inside that status bar. There are methods like GetPaneInfo, GetPaneStyle, but none returns the pane.
Thanks
|
|
|
|
|
What are you wanting to do with the pane that the CStatusBar methods do not provide? From what I can tell, the msctls_statsbar32 control does not have sub-controls (e.g., panes), thus no separate handle exists.
|
|
|
|
|
The panes in a status bar are not child windows, thus they don't have HWND s.
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
I forget (but I alway know where to start)! Look for the MFC FAQ on the web (I hope it is still maintained by Scot Wingo at Rogue Wave Software). If you want the book then look for "The MFC Answer Book" by Eugene Kain. The book will give you your answers.
Note: I recommend "The MFC Answer Book" for any-body doing Windows programing. A lot of the questions it answers could be done better using a different approch, but if you do not know where to begin then how can you improve on what you do not know.
I know the above does not directly answer your question, but (I ass-u-me) most of us need to refresh our memory every time we need to do something that seems so trivial.
|
|
|
|