我想使用以下代码在 WM_PAINT 消息处理程序中绘制很多行。
//DrawLine with double buffering
LRESULT CALLBACK CMyDoc::OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
std::vector<Gdiplus::Point> points;
std::vector<Gdiplus::Point>::iterator iter1, iter2;
HDC hdc, hdcMem;
HBITMAP hbmScreen, hbmOldBitmap;
PAINTSTRUCT ps;
RECT rect;
hdc = BeginPaint(hWnd, &ps);
//Create memory dc
hdcMem = CreateCompatibleDC(hdc);
GetClientRect(hWnd, &rect);
hbmScreen = CreateCompatibleBitmap(hdc, rect.right, rect.bottom);
hbmOldBitmap = (HBITMAP)SelectObject(hdcMem, hbmScreen);
//Fill the rect with white
FillRect(hdcMem, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
//Draw the lines
Gdiplus::Graphics graphics(hdcMem);
Gdiplus::Pen blackPen(Gdiplus::Color(255, 0, 0));
points = m_pPolyLine->GetPoints();
for (iter1 = points.begin(); iter1 != points.end(); iter1++) …Run Code Online (Sandbox Code Playgroud) #include <mutex>
#include <assert.h>
#include <iostream>
#include <unordered_map>
#include <memory>
#include <string>
#include <stdio.h>
//
// Requirements:
// 1: the bitmap could be used by multiple thread safely.(std::shared_ptr could?)
// 2: cache the bitmap and do not always increase memeory
//@NotThreadSfe
struct Bitmap {
public:
Bitmap(const std::string& filePath) {
filePath_ = filePath;
printf("foo %x ctor %s\n", this, filePath_.c_str());
}
~Bitmap() {
printf("foo %x dtor %s\n", this, filePath_.c_str());
}
std::string filePath_;
};
//@ThreadSafe
struct BitmapCache {
public:
static std::shared_ptr<Bitmap> loadBitmap(const std::string& …Run Code Online (Sandbox Code Playgroud) @implementation AVSuperView
- (AVSuperView*)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
// self.backgroundColor = [UIColor redColor];
self.layer.backgroundColor = [[UIColor redColor] CGColor];
AVLayout* avLayout = [[AVLayout alloc] init];
Run Code Online (Sandbox Code Playgroud)
在上面的自定义UIView中,例如self.backgroundColor和似乎self.layer.backgroundColor相同。是self.backgroundColor包装纸self.layer.backgroundColor吗?
我听过很多关于编程风格的重要性.在我看来,缩进很容易处理.但其他事情让我很沮丧.考虑一个特定的例子来演示inet_makeaddr的使用.
/* demonstrate the use of host address functions */
#include <stdio.h>
#include <arpa/inet.h>
#include <netinet/in.h>
int
main(void)
{
/* inet_makeaddr demo */
uint32_t neta = 0x0a3e5500;
uint32_t hosta = 0x0c;
struct in_addr alla = inet_makeaddr(neta, hosta);
printf("makeaddr of net: %08x and host: %08x = %08x\n",
neta, hosta, alla);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
有人可能想写如下:
uint32_t neta;
uint32_t hosta;
struct in_addr alla;
neta = 0x0a3e5500;
hosta = 0x0c;
alla = inet_makeaddr(neta, hosta);
Run Code Online (Sandbox Code Playgroud)
然后其他人可能总是在定义时初始化变量:
uint32_t neta = 0;
uint32_t hosta = 0;
struct …Run Code Online (Sandbox Code Playgroud) class mystring {
private:
string s;
public:
mystring(string ss) {
cout << "mystring : mystring() : " + s <<endl;
s = ss;
}
/*! mystring& operator=(const string ss) {
cout << "mystring : mystring& operator=(string) : " + s <<endl;
s = ss;
//! return this;
return (mystring&)this; // why COMPILE ERROR
} */
mystring operator=(const string ss) {
cout << "mystring : mystring operator=(string) : " + s <<endl;
s = ss;
return *this;
}
mystring operator=(const char …Run Code Online (Sandbox Code Playgroud) 在以下示例代码中,
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of …Run Code Online (Sandbox Code Playgroud) 我正在读一本关于EJB的书.它列出了EJB的旧技术的一个优点,即它可以从一个特定的应用程序服务器供应商及其专有API中释放程序员.
我想知道EJB出现之前的生活是什么?程序员在过去使用了哪种特定的应用程序服务器?你能给我一个线索吗?谢谢.
在碱2中,1/10是无限重复的部分
0.0001100110011001100110011001100110011001100110011 ...
如何让python解释器打印这种内心表示?repr(0.1)没有帮助.