|
I am preparing for my exams and i just found this question from previous question papers:
Give the C Expression for the following algebric expression :
1. ab^4c^2-d/m-n
2. ab-[{(e+f)^9}/c}]
Please help me as i am preparing for my exams and haven't read this topic yet.
help plz
|
|
|
|
|
himanshuchawla4393 wrote: and haven't read this topic yet. Then I suggest you read it; it will not help you if you just copy the answers from other people without understanding what it means. You can find all the information you need at http://msdn.microsoft.com/en-us/library/fw5abdx6.aspx[^].
|
|
|
|
|
Hi,
I am new to MFC. Can anybody tell me how to check the CDateTimeCtrl is dirty or not
Thanks in advance
|
|
|
|
|
Depends what you mean by "dirty".
|
|
|
|
|
Call its GetTime() method to get the currently selected date/time from the control. Then use COleDateTime::GetStatus() to check the validity.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
I find a error in the thread code: i call stop to screen saver in the other thread, more slow, than the thread where check if is all in stop; so the first don't know that if is all stopped; now it works - i'm sorry.
At the moment remains the problem regarding the hook: if i have the focus in my application, it works, but if i open the notepad and change focus, this hook don't works. Feel like the hook is "attacked" only on my application: It's due to the fact that the winthread object is called inside my application ? I have to change hook code ?
Thank you
Drugo
|
|
|
|
|
Today i'm find the correct way to work; i don't know why, but i'm fixed on the way to count time for starts screen saver inside my application, so i need hooks; i try to use hooks (i need global hook) and it works, but i think it's better in another way: the correct way is leave the screen saver administration to the system and enable it or disable it when occurs; the correct way is:
- Read if the screen saver is enabled from the system (so i know if i have to use it)
- If disabled i do nothing
- If enabled, disable it
- Run all on my application
- If device is sleeping for 1 minute, enable screen saver and reset counting
- If device is current in use, disable screen saver and reset counting
The rest it' better leave to the system: in this way i have only a delay of one minute for screen saver starting.
Now it works fine; i'm sorry for these post.
Thank you
Drugo
|
|
|
|
|
In an application i wrote years ago, i need to have a handle to printer propertiers device mode structure; i searched documents and i finded this function (DocumentProperties()); i searched example, i tried to use it, i writed code and the application works yet.
Now i have to write similar application and i note when i call this function, it cause a first-chance exception (only when i call it to know the size of buffer); so i try with the old application and also that cause the exception; i try to solve it, but the the example i find and the documentation i have tell me that the use of the function i make it's correct; the funny fact is this method works very well in release mode and with the old application the customer don't have problems.
The code is this:
BOOL PrinterSettings(LPTSTR pszPrinterName, BOOL bSet)
{
if (_tcslen(pszPrinterName) <= 0)
return FALSE;
if (bSet && theApp.m_hBarcodePrinterDev == NULL)
return FALSE;
PRINTER_DEFAULTS pd;
DWORD dwNeeded;
LONG lFlag;
HANDLE hPrinter = NULL;
DEVMODE FAR* pDevMode = NULL;
PRINTER_INFO_2* pPrintInfo2 = NULL;
BOOL bReturn = TRUE;
ZeroMemory(&pd, sizeof(pd));
pd.DesiredAccess = PRINTER_ALL_ACCESS;
bReturn = OpenPrinter(pszPrinterName, &hPrinter, &pd);
if (bReturn)
{
SetLastError(0);
bReturn = GetPrinter(hPrinter, 2, 0, 0, &dwNeeded);
if (!bReturn && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && dwNeeded > 0)
bReturn = TRUE;
}
if (bReturn && (dwNeeded <= 0))
bReturn = FALSE;
if (bReturn)
pPrintInfo2 = (PRINTER_INFO_2 *) GlobalAlloc (GPTR, dwNeeded);
if (bReturn && pPrintInfo2 == NULL)
bReturn = FALSE;
if (bReturn)
bReturn = GetPrinter(hPrinter, 2, (LPBYTE) pPrintInfo2, dwNeeded, &dwNeeded);
if (bReturn && pPrintInfo2->pDevMode == NULL)
{
dwNeeded = DocumentProperties(NULL, hPrinter, pszPrinterName, NULL, NULL, 0);
if (dwNeeded <= 0)
bReturn = FALSE;
if (bReturn)
pDevMode = (DEVMODE FAR*) GlobalAlloc(GHND, dwNeeded);
if (bReturn && pDevMode == NULL)
bReturn = FALSE;
if (bReturn)
{
lFlag = DocumentProperties(NULL, hPrinter, pszPrinterName, pDevMode, NULL,DM_OUT_BUFFER);
if (lFlag != IDOK || pDevMode == NULL)
bReturn = FALSE;
}
if (bReturn)
pPrintInfo2->pDevMode = pDevMode;
}
if (bReturn && pPrintInfo2->pDevMode == NULL)
bReturn = FALSE;
if (bReturn && bSet)
{
pPrintInfo2->pDevMode = (DEVMODE FAR*)::GlobalLock(theApp.m_hBarcodePrinterDev);
DWORD dwAttrib = pPrintInfo2->Attributes;
dwAttrib &= ~(PRINTER_ATTRIBUTE_WORK_OFFLINE);
pPrintInfo2->Attributes = dwAttrib;
lFlag = DocumentProperties(NULL, hPrinter, pszPrinterName, pPrintInfo2->pDevMode,
pPrintInfo2->pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER);
if (lFlag != IDOK)
bReturn = FALSE;
if (bReturn)
bReturn = SetPrinter(hPrinter, 2, (LPBYTE) pPrintInfo2, 0);
GlobalUnlock(theApp.m_hBarcodePrinterDev);
}
if (bReturn && !bSet)
{
GlobalFree(theApp.m_hBarcodePrinterDev);
dwNeeded = DocumentProperties(NULL, hPrinter, pszPrinterName, NULL, NULL, 0);
if (dwNeeded <= 0)
bReturn = FALSE;
if (bReturn)
theApp.m_hBarcodePrinterDev = ::GlobalAlloc(GPTR, dwNeeded);
if (bReturn && theApp.m_hBarcodePrinterDev == NULL)
bReturn = FALSE;
if (bReturn)
{
lFlag = DocumentProperties(NULL, hPrinter, pszPrinterName,
(DEVMODE FAR*) theApp.m_hBarcodePrinterDev, NULL, DM_OUT_BUFFER);
if (lFlag != IDOK || theApp.m_hBarcodePrinterDev == NULL)
bReturn = FALSE;
}
if (bReturn && theApp.m_hBarcodePrinterDev == NULL)
bReturn = FALSE;
}
if (pPrintInfo2)
GlobalFree(pPrintInfo2);
if (pDevMode)
GlobalFree(pDevMode);
if (hPrinter)
ClosePrinter(hPrinter);
return bReturn;
};
Something can help me ?
Thanks
Drugo
|
|
|
|
|
What is the exception and where does it occur?
|
|
|
|
|
Whene the execution arrives in one of two lines i signed, compiler write:
First-chance exception in MyApp.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in MyApp.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
but the function works normally.
Thanks
Drugo
|
|
|
|
|
These are not compiler messages, they look more like the messages you see in the debug log and can be ignored. Unless you get an exception inside your program, which causes the application to fail, you do not need to take any action.
|
|
|
|
|
... and what do you think could to be due this message ?
Thanks
Drugo
|
|
|
|
|
They are written to the debug log by the debugger; they are not being sent to the application. These exceptions are caught and handled by the system libraries.
|
|
|
|
|
I try to change printer and now i don't have no more exception.
Thank you so much for your answer.
Bye
Drugo
|
|
|
|
|
I have a technique that I use in WinAPI programs, to avoid stalling the message queue.
I start a separate thread in my program, which opens a hidden window with its own message queue. I typically call this thread the CommTask thread, since the first time I did this was to handle slow serial communications. When I want to perform a time-consuming task, I send a message to the CommTask thread using SendMessageCallback(), with a data packet telling it what to do.
When the CommTask thread completes handling of my message, my callback function gets executed.
What I don't know is, what thread is the callback function executing in?? Is it still in the CommTask thread, or has it somehow returned to my main program thread, or is there some other thread context that it executes in?
|
|
|
|
|
The documentation[^] hints at calling thread context. In any case you may easily verify it calling GetCurrentThreadId[^] inside the callback function.
Veni, vidi, vici.
|
|
|
|
|
Excellent idea!! Thank you, GetCurrentThreadId() will immediately and directly answer this question for me, I'll test it out this morning...
Yep, GetCurrentThreadId() confirmed that the callback thread executes in the context of the initiating thread.
modified 8-May-14 17:44pm.
|
|
|
|
|
Hello. I am trying to add some .C files in a new cpp project. Doing so gives me the fatal error C1853 i.e. precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa).
Now I have read a knowledge base article on microsoft forum about it which proposed 4 diffferent resolutions. I tried all of them but could not succeed (may be I couldn't understand what was required to be done). Can someone list down the steps to included .C files in cpp project. Thanks for your input.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Check properties for each of these files and set the compiler option for Precompiled Headers to "not using precompiled headers".
|
|
|
|
|
When using C files in a C++ unit you need to put an extern C around there include like this
#include "otherstuff" // you can include other c++ unit before it
extern "C" {
#include "Someunit" // include you c unit
}
#include "morestuff" // you can include other c++ units after it
In vino veritas
|
|
|
|
|
Hi,
Originally the issue was that connect() has a 20 second timeout in it. I switched to some code I found that makes the connect() not blocking, and I can certainly get program control back in 5 seconds, but this module needs to load and unload and I can't get it to unload without the full 20s wait because WSACleanup must wait for that original non blocking connect to complete before it releases.
I've tried various linger options and calling or not calling shutdown and closesocket, but nothing makes a difference. I don't want to not call WSACleanup as I figure that might be a big deal.
Is there a way to tell winsock to stop trying to connect so it doesn't wait out the 20s?
Thanks,
Alan
|
|
|
|
|
A non-blocking socket should return in like 5 micro-sec. Not 5 sec. How did you make the socket non-blocking?
-- Gisle V.
|
|
|
|
|
Sorry about the confusion - yes I am using select to make the timeout 5s. That is the timeout I would like and that part is working fine. It is the WSACleanup that isn't quickly returning that is the problem. I am hoping there is something I can do to shutdown the connect attempt before I call WSACleanup that would stop WSACleanup from taking the remaining 15s...
|
|
|
|
|
Hello.
I'm trouble in MCI T-T
this is my video spec.
General
Complete name : C:\Users\Administrator\Desktop\abdd\abc.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 5.66 MiB
Duration : 1mn 22s
Overall bit rate : 577 Kbps
Writing application : Lavf53.32.100
Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L3.0
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Format settings, GOP : M=1, N=3
Codec ID : H264
Duration : 1mn 22s
Bit rate : 575 Kbps
Width : 320 pixels
Height : 240 pixels
Display aspect ratio : 4:3
Frame rate : 12.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.623
Stream size : 5.63 MiB (100%)
when I open this video.
originally my code is...
MCI_ANIM_OPEN_PARMS *mciOpen = new MCI_ANIM_OPEN_PARMS;
mciOpen->lpstrDeviceType = _T("AVIVideo");
but It doesn't work.
This file extension name is .avi.
so I thought this lpstrDevicetype is also Avi.
but It has matter.
so now my changed code is...
MCI_ANIM_OPEN_PARMS *mciOpen = new MCI_ANIM_OPEN_PARMS;
mciOpen->lpstrDeviceType = _T("MPEGVideo");
It work!!!
1. Is it different file extension name and codec(for lpstrDeviceType) ?
2. I think my codec is lavf53.32.100 in ffmpeg, doesn't it?
so how to put code lpstrDeviceType ? MPEGVideo2, MPEGVideo4, MPEGVideo, FFMPEG??
I can't choose the lpstrDeviceType.
help me plz!
|
|
|
|
|