|
Every application (windows) has .rc file and corresponding resource.h file is there any way we can give the resource.h a different name and the classwizard will do any further modifcations of the resource to new .h file?
Thanx in advance.
Prakash.
My God is more powerfull Than Your God.
|
|
|
|
|
i don't know a method, but why do u need to rename it?
Don't try it, just do it!
|
|
|
|
|
I have a function written to switch views. I have created a menu item that has two sub menu. when the application is run the default dailog comes up. when i try to switch to the other view it is not working.
here is the code for switching the view.
void CMainFrame::SelectView(int viewID)
{
// CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
CView* pOldActiveView = GetActiveView(); // Get current view
// Get pointer to new view if it exists
// if it doesn't the pointer will be null
CView* pNewActiveView = (CView*) GetDlgItem(viewID);
// CView* pNewActiveView = static_cast<cview*>(GetDlgItem(viewID));
// If this is 1st time around for the new view,
// the new view won't exist, so we must create it
if (pNewActiveView == NULL)
{
switch(viewID)
{
case PEOPLEVIEW: // Create a People view
pNewActiveView = (CFormView*)new CPeople;
//pNewActiveView = (CView*)new CPeople;
break;
case RELATIONVIEW: // Create a Relationship view
pNewActiveView = (CView*)new CRelation;
//pNewActiveView = (CView*)new CRelation;
break;
default:
AfxMessageBox("Invalid View ID");
return;
}
// Switching the views
// Obtain the current view context to apply to the new view
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,this, viewID, &context); // the program exits with an error at this point. please help me solve this
pNewActiveView->OnInitialUpdate();
}
// Check whether there are any orders
SetActiveView(pNewActiveView); // Activate the new view
pOldActiveView->ShowWindow(SW_HIDE); // Hide the old view
pNewActiveView->ShowWindow(SW_SHOW); // Show the new view
pOldActiveView->SetDlgCtrlID(m_CurrentViewID); // Set the old view ID
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_CurrentViewID = viewID; // Save the new view ID
RecalcLayout();
}
|
|
|
|
|
I believe you need to at least specify WS_CHILD for the style, probably WS_VISIBLE as well so you can see it.
--
Joel Lucsy
|
|
|
|
|
This is how I do it.
I have two functions, one to create/add a new view to my app and the other to swap the views
void AddView(CWnd* pMainWnd, CView* pView, UINT nID)
{
CDocument* pCurrentDoc = ((CFrameWnd*) pMainWnd)->GetActiveDocument();
CCreateContext newContext;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
CRect rect(0,0,0,0);
char szTemp[64];
sprintf(szTemp, "ViewList%x", nID);
pView->Create(NULL, NULL,
(AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE),
// views are created with the style of AFX_WS_DEFAULT_VIEW
// In MFC 4.0, this is (WS_BORDER | WS_VISIBLE | WS_CHILD)
rect, pMainWnd,
nID, &newContext);
pView->SendMessage(WM_INITIALUPDATE, 0, 0);
}
CView* SwitchView(CFrameWnd* pFrame, CView* pNewView)
{
CView* pActiveView = pFrame->GetActiveView();
UINT temp = ::GetWindowLong(pActiveView->m_hWnd, GWL_ID);
::SetWindowLong(pNewView->m_hWnd, GWL_ID, temp);
if(pActiveView == pNewView)
return pActiveView;
// Resize new view to fit the frame - bug fix MB 14/03/02
CRect rect;
pFrame->GetClientRect(&rect);
pNewView->MoveWindow(&rect);
pActiveView->ShowWindow(SW_HIDE);
pFrame->RecalcLayout();
pFrame->SetActiveView(pNewView);
pNewView->ShowWindow(SW_SHOW);
pNewView->Invalidate();
return pActiveView;
}
// Each view needs an ID
#define VIEWS_CALLLIST_VIEW AFX_IDW_PANE_FIRST
#define VIEWS_TRANSFER_VIEW AFX_IDW_PANE_FIRST + 1
// In the WinApp derived class, create the views
void CReceptionApp::SetupViews()
{
// Get the primary view
CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
m_pReceptionView = (CReceptionView*) pActiveView;
// Create the second view
m_pTransferView = new CTransferView;
AddView(m_pMainWnd, m_pTransferView, VIEWS_TRANSFER_VIEW);
}
// Switch the view - I usually call this in the CMainFrame class
SwitchView(this, GetApp()->GetTransferView());
Michael
|
|
|
|
|
Hi,
Whenever a pointer is not allocated, something like this,
CClass *myObj;
It is pointing to some address like 0xccddff.
I know that the address is junk. Why it is always like 0xccdeff or 0xdeffcc?? Why it is not like 0x102033??
So, before allocation of memory it is pointing to some place, which is junk. But, where is that junk area? or which is the area used where the not allocated pointer points to?
Best Regards,
A.Ilamparithi
|
|
|
|
|
The compiler sets this up for you (in debug builds only) so that you can find bugs quickly if you accidentally use the pointer without initializing it. It also does a similar thing with dynamically allocated blocks of memory.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 1.1.4 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
|
Hello, i've got a problem with a Combobox as dropdown! If I have changed the Edit Control, I would paste the EnterKey! I have no reaction! How I can find the VK_RETURN ?
please help
|
|
|
|
|
Umm..
You have a combobox with the 'dropdown' style set. That far I understand. Beyond this sentence your description of the problem becomes simply too illogical to understand. In english: your typing sucks big time
Could you clarify a bit ? What is it that you are actually trying to accomplish ? Must the edit control attached to the combo box be able to handle return keypresses ?
"You cannot paste a 'EnterKey'" That makes no sense. Are you, per chance, willing to paste a string into the edit control, and this string contains a LF-CR (line feed - carriage return) pair or line change formatting ('\n') ?
The more in detail and clearly you can describe your problem, the more better we can help you. Always when posting a message, remember to check it for spelling errors or typoes. A typo can change the context of a sentence completely, making us misunderstand you completely.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Ok,
also i have a list ! Bsp: 1
3
25
76
111
546
3333
4711
Then i change manuell the entry! Bsp 56 then i hit "Enter"! -> then i want start onaccept! If then manuell entry not in List! Messagebox: Entry not in List!
else setCursel manuell entry!
.....
|
|
|
|
|
OK I think I know what you're on about.
You can override the CBN_SELCHANGE message for your combobox using ClassWizard (VS6). This will create the OnSelChangeXXX() function handler that gets called wheneveer your user selects a new item from your combo control, or types in a new entry.
You can then use this handler to determine if the entry is already in your list, or not (Where you wanted to popup a message box).
Another way would probably be to set the CBS_DROPDOWNLIST style programatically, or via the resource editor. This will force the user to select items that are in the list instead of entering their own items.
Hope this helps.
I Dream of Absolute Zero
|
|
|
|
|
Can i open the select list when everyone change the edit control?
OnEditChange() ?
When the selectlist is open, the Enterkey is OK!
|
|
|
|
|
Now you've lost me again!
those automated translators are a b*tch aren't they?
I Dream of Absolute Zero
|
|
|
|
|
Referring to the MSDN, there is no prepared override which allows you to hack into the message stream of a combo box.
However, there is a way. It requires that you derive a new class from CComboBox, and put a message map entry for 'ON_WM_CHAR' messages. Route these messages to a handler function, and if the message contains the virtual key VK_RETURN, you start the copying routine.
In this routine, you first use GetWindowText to get the current text in the combo box's edit control. Then you use a combination of GetCurSel , DeleteString and InsertString methods to replace the currently selected string with the new string you typed in.
The default handler of the VK_RETURN keypress attempts to search for the inserted string in the list. You must override this handler in order to implement custom functionality. Remember to call the base class handler for other keypresses, otherwise your combo box might not work properly.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Ok I have forgotten to say, if the entry correct send a message to a server!
Update the Database about time and Date!
I have a subclass DCCombobox!
/* --------------------------------------------------------------------
* Message-Map definieren
* ------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(DCComboBox, CComboBox)
ON_WM_KEYUP()
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
int DCComboBox::OnCreate( LPCREATESTRUCT lpCreateStruct ){
return CComboBox::OnCreate(lpCreateStruct);
}
void DCComboBox::OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags ) {
CWnd* parent = GetParent();
if( parent )
parent->PostMessage( WM_KEYDOWN,(WPARAM)nChar,
MAKELONG (nRepCnt,nFlags) );
CComboBox::OnKeyDown(nChar,nRepCnt,nFlags);
}
void DCComboBox::OnKeyUp(UINT nChar,UINT nRepCnt,UINT nFlags ) {
CWnd* parent = GetParent();
if( parent )
parent->PostMessage( WM_KEYUP, (WPARAM)nChar,
MAKELONG(nRepCnt,nFlags) );
CComboBox::OnKeyUp(nChar,nRepCnt,nFlags);
}
|
|
|
|
|
You're simply not making any sense. I am completely loss of what you are trying to do.
Ask a friend of yours to do an accurate translation of what you want to do and post that as a message. Otherwise we cannot help you any further, as we can't understand your motives at all.
The code you posted works correctly, as far as I can tell: it posts a message to the parent window when a keyboard event is received in the combo box control. Is this what you wanted to do ?
What is this 'send a message to server' ? What server ? Time ? Date ?? Database ??? You've completely shaken us. Start forming your problem anew, and this time ask a friend who has qualified english skills to translate it for you, so it will be easier for us to read.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
i have made an app which connects to IE and Netscape via DDE and tells the currently loaded URL
it is working fine with IE but
not with Netscape
netscape connects with NSShell,NETSCAPE and NSCMDLINE
but doesn't tell the URL
which of these three should i connect too
please Help
|
|
|
|
|
Looking at the Netscape's DDE Implementation guide (found here[^]), following details are described:
The DDE service name for Netscape browser is 'NETSCAPE'. The request for obtaining information about a page shown in a window can be obtained by sending a WWW_GetWindowInfo request, which is of type XTYP_REQUEST .
You can see these topics yourself by going to the specified web page.
Here is an MSDN link about using DDE for your convinience: Using Dynamic Data Exchange[^]
Hope this helps,
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
i have 2 list control says IDC_LIST1 and IDC_LIST2.
I am not using class wizard here. I am declaring in header file using afxmessage ie. afx_msg void OnItemclickList1(NMHDR* pNMHDR, LRESULT* pResult);
and on_NOTIFY ie ON_NOTIFY(HDN_ITEMCLICK, 0, OnItemclickList1)
I have one more list control ie IDC_LIST2 when i declare afxmessage and ON_NOTIFY, the control do not go there. it goes only for the first control.
even after giving the proper ID of the control instead of giving zero. I tried using the single function and then by finding out the ID, but it gives the same id for both the control, i dont get the id of the control( it could be id of the view where this control are placed).
what should be declaration in the BEGIN MESSAGE , END MESSAGE MAP. and how do i differentiate between this 2 controls.
abdul
|
|
|
|
|
hi people ,
any idea about how to convert a jpg/bmp file to .pcx format......
i also have to save the bmp file into vector image format ....any idea about how to go about it????????
|
|
|
|
|
Have a look to this[^] article, it may help.
HTH,
K.
Le temps se perd, "Si" n'existe pas
Tous les remords n'y changeront rien
Le temps se perd, "Si" n'existe pas
Donc à présent le choix reste mien
|
|
|
|
|
I found these words in the MSDN: "Global variables in a DLL source code file are global to each process using the DLL." I know this to be true, because the following dll and app work for me:
----- stupidDll.h -----
#ifndef STUPIDDLL_H
#define STUPIDDLL_H
int __declspec(dllexport) getStupidInt();
#endif
-------------------------
----- stupidDll.cpp -----
#include "stupidDll.h"
int x = 7;
int getStupidInt() { return x; }
-------------------------
----- stupidApp.cpp -----
#include "stupidDll.h"
#include "stdio.h
int main() {
printf("%d %d\n", getStupidInt());
return 0;
}
-------------------------
But say I don't want to have to call a function to get at the value of x. Shouldn't there be someway to export the symbol x in the DLL (just like I can export the symbol getStupidInt()) ?
I.e., I want to be able to have something like:
extern int x;
in stupidDll.h so that applications can reference this global data directly. I presume I need some sort of __declspec on the above, but I haven't been able to figure it out yet. In case it matters, the data I want to export are a couple of C++ objects -- not simple ints.
Thanks much,
Matt Busche
|
|
|
|
|
Have you tried to put in your DLL header the following declaration?
extern __declspec(dllexport) int x;
and in the DLL code:
int x;
PS. IMHO, global variables suck, especially in an OO design.
Le temps se perd, "Si" n'existe pas
Tous les remords n'y changeront rien
Le temps se perd, "Si" n'existe pas
Donc à présent le choix reste mien
|
|
|
|
|
KaЯl,
Yes. Actually that was the first thing I tried. I get:
stupidApp.obj : error LNK2001: unresolved external symbol "int x" (?x@@3HA)
stupidAp/stupidApp.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
And yes, in general I agree global variables (or in my case objects) suck, but if you knew what I was doing, I suspect you might forgive me. But I am not going to defend myself here. Never-the-less I appreciate your response and would be interested in any other ideas you may have.
Thanks,
Matt
|
|
|
|
|