|
After a little research I have seen the error of my ways.
The problam was, I was creating a bitmap to the size of the paper in pixels. Obviously the pixel count in a print DC is substantialy higher than the of the screen. In effect of was creating a bitmap some 3000x5000 pixels and sending that to the printer.
I have now changed it to create a bitmap of (842,595) which is what my paint program creates when selecting A4 size. This has reduced the file size to under 2mb with no apparent distortion. Since I am unable to test this on a real printer, I just hope it is correct.
|
|
|
|
|
Hi waldermort ,
for test your program you can use virtual printer
|
|
|
|
|
|
If the menu items do not have handlers ( ON_COMMAND ) they will be disabled by default.
If you want to have them enabled, either had handlers for the command or and update handlers ( ON_UPDATE_COMMAND_UI ) to enablet the menu item.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
try this to solve it:
<br />
m_cMenu.EnableMenuItem(IDC_FILE_SAVE, MF_ENABLED);<br />
m_cMenu.EnableMenuItem(IDC_FILE_SAVE_AS, MF_ENABLED);<br />
<br />
m_cMenu.EnableMenuItem(IDC_FILE_SAVE, MF_DISABLED | MF_GRAYED);<br />
m_cMenu.EnableMenuItem(IDC_FILE_SAVE_AS, MF_DISABLED | MF_GRAYED); <br />
i hope this can help you!
regards
break;
|
|
|
|
|
hi,
try to enable/disable them after you create them?! If create is successful try to enable/disable?!
I have them static in my dialog!
regards
break;
|
|
|
|
|
Inside your MDI MainFrame Constructor set this boolean variable to FALSE
m_bAutoMenuEnable = FALSE;
Nibu thomas
Software Developer
|
|
|
|
|
i have to create a list view where u can edit subitems.( non MFC one)
I refered the article by Mr.Zafir
http://www.codeguru.com/cpp/controls/listview/editingitemsandsubitem/article.php/c923/
i am unable to trace when the functions in the class(here: CInPlaceEdit) which is derived from the CEdit are invoked or called.
It has something like this... in the .h file
//{{AFX_MSG(CInPlaceEdit)
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnNcDestroy();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
in the .cpp file
BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
//{{AFX_MSG_MAP(CInPlaceEdit)
ON_WM_KILLFOCUS()
ON_WM_NCDESTROY()
ON_WM_CHAR()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
as this is not valid in a non MFC one .. i used something like this. in the .h file
BEGIN_MSG_MAP(CInPlaceEdit)
MESSAGE_HANDLER(WM_NCDESTROY, OnNcDestroy)
MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
MESSAGE_HANDLER(WM_CHAR, OnChar)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
END_MSG_MAP()
LRESULT OnNcDestroy(UINT nMsg, WPARAM wParam, LPARAM lparam, BOOL& bHandled);
LRESULT OnKillFocus(UINT nMsg, WPARAM wParam, LPARAM lparam, BOOL& bHandled);
LRESULT OnChar(UINT nMsg, WPARAM wParam, LPARAM lparam, BOOL& bHandled);
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lparam, BOOL& bHandled);
what i want to know is how to call these functions or how to invoke them or
when are they called(from where).
right now they are not been called?
i am just able to create the edit control at a particular sub item location...
Plz Plz help me ragarding this..
Thank in advance.
|
|
|
|
|
I think you are going bout this the wrong way. In non-MFC you don't need to create a seperate function for windows message, you simply need to handle them in the parent window of your control.
Normally you would use
switch (message) {
case WM_KILLFOCUS:
break;
case WM_CHAR:
break;
}
For list views you should consult MSDN for exactly what messages are sent and where to trap them (for list views usually they are in the form of a WM_NOTIFY). there are also some good articles on here about how to handle windows messages.
|
|
|
|
|
Hi friends,
i want to develop an application wherein i need to send ".txt"(size may vary aroung 1MB) files across the network(LAN) from one computer to another. So i want to know which will be the simplest and easiest way to do it? will it be sockets or TCP/IP or DCOM(i know this thing is very tough..).
since performance(speed) is not so important i'd like to know the simplest method to do this.
Thanks and regards,
Rajeev
|
|
|
|
|
Hello, i suggest you consider the TCP/IP sockets for your application. Good luck.
|
|
|
|
|
You could always do the copy yourself to a UNC sharename on the target computer.
onwards and upwards...
|
|
|
|
|
Iam using CDHTMLViewSpec class.
I have designed a page in html in which on left side some links are there say Link1, Link2 & so on.When user clicks a perticular link Iam showing the details about it in the table which is on right side of this page (help window)
In Help window there are two hyper link “Previous” and “next”.
I want to keep track of links which user visited last time and accordingly navigate to Previous or Next Link.
Can any one tell me how this could be done or please tell me any website where I can find help about this.
Thank you.
|
|
|
|
|
Hi,
Recently I wrote simple code like that:
//
COleDateTime dt(2006,02,30,1,1,1);
if (dt.GetStatus() == COleDateTime::valid) {
AfxMessageBox("valid");
}
else {
AfxMessageBox("NOT valid");
}
///
It shows message box "valid" in VS.NET 2003 ! Am I crazy ? Or sth is wrong ?
It shows message box "NOT valid" in VS 6.0.
Best regards,
Irek Olchawski.
|
|
|
|
|
You might find this[^] useful.
Thanks for the heads-up . The apps that I write uses this class a lot and could, in theory, be severly affected by this.
I Dream of Absolute Zero
|
|
|
|
|
Guys,
(i) Having website www.abc.com (Root Foldercontains asp files)Using CHttpConnection (OpenRequest, SendRequest)am calling root files, and pass the URL,its work superbly.
(ii)Now I'm changing the site abc.com to xyz.com and using IIS settings I redirected the same.
(iii) problem is when I pass the url in abc.com (calling new website xyz thru old one.)The new one xyz.com is
not calling properly.
As I need it very urgently! Any quick helps and suggestion
will be great.
Thanks
Vivek.S
You only have to do a very few things right in your life so long as you don't do too many things wrong.
|
|
|
|
|
hi,
I needed a small help regarding the code which i have written in VC++ to get the status of a printer like ''PRINTER_STATUS_NO_TONER", "PRINTER_STATUS_PAPER_JAM" etc..
I have written the following code:
char szPrinter[255];
memset(szPrinter,'\0',255);
strcpy(szPrinter,m_szPrinterName.operator LPCTSTR());
BOOL bSuccess = FALSE;
HANDLE hPrinter = NULL;
PRINTER_DEFAULTS *lpDefaults = NULL;
BOOL bOpen = ::OpenPrinter(szPrinter, &hPrinter, lpDefaults);
DWORD dwBytesReturned;
DWORD dwBytesNeeded;
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
PRINTER_INFO_2 *pPrinterInfo = (PRINTER_INFO_2*)GlobalAlloc(GPTR,dwBytesNeeded);
bSuccess = ::GetPrinter(hPrinter, 2, (LPBYTE)pPrinterInfo,dwBytesNeeded, &dwBytesReturned);
uint32 dwStatusID = 0;
switch(pPrinterInfo->Status)
{
case PRINTER_STATUS_BUSY:
dwStatusID = ID_STAT_PRN_BUSY;
bSuccess = TRUE;
break;
case PRINTER_STATUS_DOOR_OPEN:
dwStatusID = ID_STAT_PRN_DOOR_OPEN;
bSuccess = TRUE;
break;
case PRINTER_STATUS_ERROR:
dwStatusID = ID_STAT_PRN_ERROR;
bSuccess = FALSE;
break;
case PRINTER_STATUS_INITIALIZING:
dwStatusID = ID_STAT_PRN_INITIALIZING;
bSuccess = TRUE;
break;
case PRINTER_STATUS_IO_ACTIVE:
dwStatusID = ID_STAT_PRN_IO_ACTIVE;
bSuccess = TRUE;
break;
case PRINTER_STATUS_MANUAL_FEED:
dwStatusID = ID_STAT_PRN_MANUAL_FEED;
bSuccess = TRUE;
break;
case PRINTER_STATUS_NO_TONER:
dwStatusID = ID_STAT_PRN_NO_TONER;
bSuccess = FALSE;
break;
case PRINTER_STATUS_NOT_AVAILABLE:
dwStatusID = ID_STAT_PRN_NOT_AVAILABLE;
bSuccess = FALSE;
break;
case PRINTER_STATUS_OFFLINE:
dwStatusID = ID_STAT_PRN_OFFLINE;
bSuccess = TRUE;
break;
case PRINTER_STATUS_OUT_OF_MEMORY:
dwStatusID = ID_STAT_PRN_OUT_OF_MEMORY;
bSuccess = FALSE;
break;
case PRINTER_STATUS_OUTPUT_BIN_FULL:
dwStatusID = ID_STAT_PRN_OUTPUT_BIN_FULL;
bSuccess = TRUE;
break;
case PRINTER_STATUS_PAGE_PUNT:
dwStatusID = ID_STAT_PRN_PAGE_PUNT;
bSuccess = FALSE;
break;
case PRINTER_STATUS_PAPER_JAM:
dwStatusID = ID_STAT_PRN_PAPER_JAM;
bSuccess = FALSE;
break;
case PRINTER_STATUS_PAPER_OUT:
dwStatusID = ID_STAT_PRN_PAPER_OUT;
bSuccess = FALSE;
break;
case PRINTER_STATUS_PAPER_PROBLEM:
dwStatusID = ID_STAT_PRN_PAPER_PROBLEM;
bSuccess = FALSE;
break;
case PRINTER_STATUS_PAUSED:
dwStatusID = ID_STAT_PRN_PAUSED;
bSuccess = TRUE;
break;
case PRINTER_STATUS_PENDING_DELETION:
dwStatusID = ID_STAT_PRN_PENDING_DELETION;
bSuccess = FALSE;
break;
case PRINTER_STATUS_POWER_SAVE:
dwStatusID = ID_STAT_PRN_POWER_SAVE;
bSuccess = TRUE;
break;
case PRINTER_STATUS_PRINTING:
dwStatusID = ID_STAT_PRN_PRINTING;
bSuccess = TRUE;
break;
case PRINTER_STATUS_PROCESSING:
dwStatusID = ID_STAT_PRN_PROCESSING;
bSuccess = TRUE;
break;
case PRINTER_STATUS_SERVER_UNKNOWN:
dwStatusID = ID_STAT_PRN_SERVER_UNKNOWN;
bSuccess = FALSE;
break;
case PRINTER_STATUS_TONER_LOW:
dwStatusID = ID_STAT_PRN_TONER_LOW;
bSuccess = TRUE;
break;
case PRINTER_STATUS_USER_INTERVENTION:
dwStatusID = ID_STAT_PRN_USER_INTERVENTION;
bSuccess = FALSE;
break;
case PRINTER_STATUS_WAITING:
dwStatusID = ID_STAT_PRN_WAITING;
bSuccess = TRUE;
break;
case PRINTER_STATUS_WARMING_UP:
dwStatusID = ID_STAT_PRN_WARMING_UP;
bSuccess = TRUE;
break;
case 0:
bSuccess = TRUE;
break;
default:
dwStatusID = PRINTER_STATUS_SERVER_UNKNOWN;
bSuccess = FALSE;
break;
}
The above code works fine for a parallel port network printer,but the "pPrinterInfo->Status" parameter returns "0" for a local USB printer.
Can anyone kindly tell me what may be the problem.
|
|
|
|
|
Hi,
CMenu* pMenu = GetMenu();
ASSERT (pMenu != NULL);
for(int i=0;i< (int)pMenu->GetMenuItemCount();i++)
{
CMenu* pActionMenu = pMenu->GetSubMenu(i);
ASSERT (pActionMenu != NULL);
int nMenuItemCount = pActionMenu->GetMenuItemCount();
int nTemp = nMenuItemCount-1 ;
nMenuItemCount=nMenuItemCount-1;
while (nMenuItemCount >= 0)
{
if(!(i==0 && nMenuItemCount==nTemp))
{
pActionMenu->RemoveMenu(nMenuItemCount, MF_BYPOSITION);
//pActionMenu->EnableMenuItem( pActionMenu->GetMenuItemID
(nMenuItemCount) ,MF_BYCOMMAND|MF_DISABLED);
}
nMenuItemCount=nMenuItemCount-1;
}
}
Requirement : Disabling all menu items
I have used the above code snippet to removing Menu items in my application.
But when i attempt to use EnableMenuItem for disabling than removing it fails.
Can any one show some light on this?
for thendral
|
|
|
|
|
RemoveMenu: Deletes a menu item with an associated pop-up menu from the menu.
Try using same function i.e EnableMenuItem for enabling & diabling the menu items.
Regards,
Ashok.
|
|
|
|
|
Use ON_UPDATE_COMMAND_UI .
Nibu thomas
Software Developer
|
|
|
|
|
I can use ON_UPDATE_COMMAND_UI if i need to disable a single menu item
My requirement is to disable all menus in a single shot,How can this be done.
Thanks
for thendral
|
|
|
|
|
Hi, I think that the only solutions is to disable each item of your menu. There isn't other way to make this. Sorry and good coding!
|
|
|
|
|
You can use ON_UPDATE_COMMAND_UI_RANGE . There are certain limitations too.
Nibu thomas
Software Developer
|
|
|
|
|
From Code Project articles i have coded a C++ DLL to be used as a global hook for C# projects. I have been successful in getting a global keyboard hook working. But when i try the same with a mouse hook, computer CPU goes to 100% and C# app gets a million messages that say the same thing. I am not the greatest C++ programmer. Am i missing something here? I think i have all the code parts needed?
Below is the code i am using (40+ lines):
#include "stdafx.h"
#include "hookdll.h"
#pragma data_seg("SHARED")
HHOOK m_mouseHook = NULL;
HWND m_hHookClient = NULL;
#pragma data_seg()
#pragma comment(linker, "/SECTION:SHARED,RWS") // linker directive
HINSTANCE m_hHookDLL = NULL;
const int GH_MOUSEOTHER = WM_USER + 4099;
BOOL APIENTRY DllMain(
HANDLE hInstance,
DWORD callReason,
LPVOID reserved)
{
switch (callReason)
{
case DLL_PROCESS_ATTACH:
m_hHookDLL = (HINSTANCE)hInstance;
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) void InstallHook(HWND hWnd)
{
m_mouseHook = NULL;
m_hHookClient = hWnd;
// set mouse hook
m_mouseHook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)MouseHookProc,
m_hHookDLL, NULL);
}
extern "C" __declspec(dllexport) void RemoveHook()
{
UnhookWindowsHookEx(m_mouseHook);
}
LRESULT CALLBACK MouseHookProc(
int nCode,
WPARAM wParam,
LPARAM lParam)
{
if (nCode >= 0)
{
PostMessage(m_hHookClient, GH_MOUSEOTHER, wParam, lParam);
}
// pass control to next hook in the hook chain
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
-- modified at 6:15 Wednesday 22nd March, 2006
|
|
|
|
|
Hi,
is it possible for me to code a program in c++ to gather all URLs contained in a website/webpage?
or if not does anyone have a code to find URLs in a text file?
Does anyone have a sample code or a link that may give me information about this?
Your help will be appreciated. Thanks in advance
|
|
|
|